Blob Blame History Raw
2009-03-18  Jakub Jelinek  <jakub@redhat.com>

	PR debug/38757
	* langhooks.h (struct lang_hooks): Add source_language langhook.
	* langhooks-def.h (LANG_HOOKS_SOURCE_LANGUAGE): Define to NULL.
	(LANG_HOOKS_INITIALIZER): Add LANG_HOOKS_SOURCE_LANGUAGE.
	* c-lang.c (c_source_language): New function.
	(LANG_HOOKS_SOURCE_LANGUAGE): Define.
	* dwarf2out.c (add_prototyped_attribute): Add DW_AT_prototype
	also for DW_LANG_{C,C99,ObjC}.
	(gen_compile_unit_die): Use lang_hooks.source_language () to
	determine if DW_LANG_C99 or DW_LANG_C89 should be returned.

--- gcc/langhooks.h.jj	2009-03-02 09:45:47.000000000 +0100
+++ gcc/langhooks.h	2009-03-18 12:53:24.000000000 +0100
@@ -1,5 +1,5 @@
 /* The lang_hooks data structure.
-   Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
+   Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
    Free Software Foundation, Inc.
 
 This file is part of GCC.
@@ -414,6 +414,10 @@ struct lang_hooks
      if in the process TREE_CONSTANT or TREE_SIDE_EFFECTS need updating.  */
   tree (*expr_to_decl) (tree expr, bool *tc, bool *se);
 
+  /* Return year of the source language standard version if the FE supports
+     multiple versions of the standard.  */
+  int (*source_language) (void);
+
   /* Whenever you add entries here, make sure you adjust langhooks-def.h
      and langhooks.c accordingly.  */
 };
--- gcc/langhooks-def.h.jj	2009-03-02 09:45:47.000000000 +0100
+++ gcc/langhooks-def.h	2009-03-18 12:53:45.000000000 +0100
@@ -1,5 +1,5 @@
 /* Default macros to initialize the lang_hooks data structure.
-   Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
+   Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
    Free Software Foundation, Inc.
    Contributed by Alexandre Oliva  <aoliva@redhat.com>
 
@@ -113,6 +113,7 @@ extern void lhd_omp_firstprivatize_type_
 #define LANG_HOOKS_EXPR_TO_DECL		lhd_expr_to_decl
 #define LANG_HOOKS_TO_TARGET_CHARSET	lhd_to_target_charset
 #define LANG_HOOKS_INIT_TS		lhd_do_nothing
+#define LANG_HOOKS_SOURCE_LANGUAGE	NULL
 
 /* Attribute hooks.  */
 #define LANG_HOOKS_ATTRIBUTE_TABLE		NULL
@@ -270,6 +271,7 @@ extern tree lhd_make_node (enum tree_cod
   LANG_HOOKS_BUILTIN_FUNCTION_EXT_SCOPE, \
   LANG_HOOKS_INIT_TS,          \
   LANG_HOOKS_EXPR_TO_DECL, \
+  LANG_HOOKS_SOURCE_LANGUAGE, \
 }
 
 #endif /* GCC_LANG_HOOKS_DEF_H */
--- gcc/c-lang.c.jj	2009-02-20 15:06:14.000000000 +0100
+++ gcc/c-lang.c	2009-03-18 13:33:41.000000000 +0100
@@ -1,6 +1,6 @@
 /* Language-specific hook definitions for C front end.
    Copyright (C) 1991, 1995, 1997, 1998,
-   1999, 2000, 2001, 2003, 2004, 2005, 2007, 2008
+   1999, 2000, 2001, 2003, 2004, 2005, 2007, 2008, 2009
    Free Software Foundation, Inc.
 
 This file is part of GCC.
@@ -37,6 +37,12 @@ along with GCC; see the file COPYING3.  
 
 enum c_language_kind c_language = clk_c;
 
+static int
+c_source_language (void)
+{
+  return flag_isoc99 ? 1999 : 1989;
+}
+
 /* Lang hooks common to C and ObjC are declared in c-objc-common.h;
    consequently, there should be very few hooks below.  */
 
@@ -44,6 +50,8 @@ enum c_language_kind c_language = clk_c;
 #define LANG_HOOKS_NAME "GNU C"
 #undef LANG_HOOKS_INIT
 #define LANG_HOOKS_INIT c_objc_common_init
+#undef LANG_HOOKS_SOURCE_LANGUAGE
+#define LANG_HOOKS_SOURCE_LANGUAGE c_source_language
 
 /* Each front end provides its own lang hook initializer.  */
 const struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER;
--- gcc/dwarf2out.c.jj	2009-03-17 13:06:29.000000000 +0100
+++ gcc/dwarf2out.c	2009-03-18 12:55:36.000000000 +0100
@@ -14286,9 +14286,18 @@ add_bit_size_attribute (dw_die_ref die, 
 static inline void
 add_prototyped_attribute (dw_die_ref die, tree func_type)
 {
-  if (get_AT_unsigned (comp_unit_die, DW_AT_language) == DW_LANG_C89
-      && TYPE_ARG_TYPES (func_type) != NULL)
-    add_AT_flag (die, DW_AT_prototyped, 1);
+  switch (get_AT_unsigned (comp_unit_die, DW_AT_language))
+    {
+    case DW_LANG_C:
+    case DW_LANG_C89:
+    case DW_LANG_C99:
+    case DW_LANG_ObjC:
+      if (TYPE_ARG_TYPES (func_type) != NULL)
+	add_AT_flag (die, DW_AT_prototyped, 1);
+      break;
+    default:
+      break;
+    }
 }
 
 /* Add an 'abstract_origin' attribute below a given DIE.  The DIE is found
@@ -16290,6 +16299,10 @@ gen_compile_unit_die (const char *filena
 	language = DW_LANG_ObjC;
       else if (strcmp (language_string, "GNU Objective-C++") == 0)
 	language = DW_LANG_ObjC_plus_plus;
+      else if (strcmp (language_string, "GNU C") == 0
+	       && lang_hooks.source_language
+	       && lang_hooks.source_language () >= 1999)
+	language = DW_LANG_C99;
     }
 
   add_AT_unsigned (die, DW_AT_language, language);