Use new language types for objc, objc++

Geoffrey Keating gkeating@apple.com
Sat Mar 25 00:51:00 GMT 2006


This patch causes GCC to use the new language types for objc and
objc++.

I think it's actually a bug that GCC will say that the language is C89
if it doesn't know; it should just not provide a DW_AT_language
attribute in that case.  But, I'm not sure what that breaks, so I
haven't done it in this patch.  I also didn't make GCC output
DW_LANG_C99 for similar reasons.

Bootstrapped & tested on powerpc-darwin8, with objc++ enabled.

-- 
- Geoffrey Keating <geoffk@apple.com>

===File ~/patches/gcc-dwarf-objclang.patch==================
Index: ChangeLog
2006-03-24  Geoffrey Keating  <geoffk@apple.com>

	* dwarf2out.c (is_c_family): Understand new DWARF3 language types.
	(is_cxx): Likewise.
	(gen_compile_unit_die): Use new language types for Objective-C and
	Objective-C++.
	(dwarf2out_decl): Use is_cxx rather than testing explicitly against
	DW_LANG_C_plus_plus.

Index: testsuite/ChangeLog
2006-03-24  Geoffrey Keating  <geoffk@apple.com>

	* objc.dg/dwarf-2.m: New.
	* obj-c++.dg/dwarf-2.mm: New.

Index: testsuite/objc.dg/dwarf-2.m
===================================================================
--- testsuite/objc.dg/dwarf-2.m	(revision 0)
+++ testsuite/objc.dg/dwarf-2.m	(revision 0)
@@ -0,0 +1,3 @@
+/* { dg-options "-gdwarf-2 -dA" } */
+/* { dg-final { scan-assembler "0x10\[^0-9a-f\].*DW_AT_language" } } */
+int x;
Index: testsuite/obj-c++.dg/dwarf-2.mm
===================================================================
--- testsuite/obj-c++.dg/dwarf-2.mm	(revision 0)
+++ testsuite/obj-c++.dg/dwarf-2.mm	(revision 0)
@@ -0,0 +1,3 @@
+/* { dg-options "-gdwarf-2 -dA" } */
+/* { dg-final { scan-assembler "0x11\[^0-9a-f\].*DW_AT_language" } } */
+int x;
Index: dwarf2out.c
===================================================================
--- dwarf2out.c	(revision 112362)
+++ dwarf2out.c	(working copy)
@@ -5326,8 +5326,9 @@
 {
   unsigned int lang = get_AT_unsigned (comp_unit_die, DW_AT_language);
 
-  return (lang == DW_LANG_C || lang == DW_LANG_C89
-	  || lang == DW_LANG_C_plus_plus);
+  return (lang == DW_LANG_C || lang == DW_LANG_C89 || lang == DW_LANG_ObjC
+	  || lang == DW_LANG_C99
+	  || lang == DW_LANG_C_plus_plus || lang == DW_LANG_ObjC_plus_plus);
 }
 
 /* Return TRUE if the language is C++.  */
@@ -5335,8 +5336,9 @@
 static inline bool
 is_cxx (void)
 {
-  return (get_AT_unsigned (comp_unit_die, DW_AT_language)
-	  == DW_LANG_C_plus_plus);
+  unsigned int lang = get_AT_unsigned (comp_unit_die, DW_AT_language);
+  
+  return lang == DW_LANG_C_plus_plus || lang == DW_LANG_ObjC_plus_plus;
 }
 
 /* Return TRUE if the language is Fortran.  */
@@ -12204,6 +12206,10 @@
     language = DW_LANG_Pascal83;
   else if (strcmp (language_string, "GNU Java") == 0)
     language = DW_LANG_Java;
+  else if (strcmp (language_string, "GNU Objective-C") == 0)
+    language = DW_LANG_ObjC;
+  else if (strcmp (language_string, "GNU Objective-C++") == 0)
+    language = DW_LANG_ObjC_plus_plus;
   else
     language = DW_LANG_C89;
 
@@ -13314,8 +13320,7 @@
 	{
 	  /* OK, we need to generate one for `bool' so GDB knows what type
 	     comparisons have.  */
-	  if ((get_AT_unsigned (comp_unit_die, DW_AT_language)
-	       == DW_LANG_C_plus_plus)
+	  if (is_cxx ()
 	      && TREE_CODE (TREE_TYPE (decl)) == BOOLEAN_TYPE
 	      && ! DECL_IGNORED_P (decl))
 	    modified_type_die (TREE_TYPE (decl), 0, 0, NULL);
============================================================



More information about the Gcc-patches mailing list