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