Blame gcc44-pr38757.patch

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