|
|
8178f7 |
2009-03-18 Jakub Jelinek <jakub@redhat.com>
|
|
|
8178f7 |
|
|
|
8178f7 |
PR debug/38757
|
|
|
8178f7 |
* langhooks.h (struct lang_hooks): Add source_language langhook.
|
|
|
8178f7 |
* langhooks-def.h (LANG_HOOKS_SOURCE_LANGUAGE): Define to NULL.
|
|
|
8178f7 |
(LANG_HOOKS_INITIALIZER): Add LANG_HOOKS_SOURCE_LANGUAGE.
|
|
|
8178f7 |
* dwarf2out.c (add_prototyped_attribute): Add DW_AT_prototype
|
|
|
8178f7 |
also for DW_LANG_{C,C99,ObjC}.
|
|
|
8178f7 |
(gen_compile_unit_die): Use lang_hooks.source_language () to
|
|
|
8178f7 |
determine if DW_LANG_C99 or DW_LANG_C89 should be returned.
|
|
|
8178f7 |
c/
|
|
|
8178f7 |
* c-lang.c (c_source_language): New function.
|
|
|
8178f7 |
(LANG_HOOKS_SOURCE_LANGUAGE): Define.
|
|
|
8178f7 |
|
|
|
8178f7 |
--- gcc/langhooks.h.jj 2011-01-03 12:53:05.125745450 +0100
|
|
|
8178f7 |
+++ gcc/langhooks.h 2011-01-04 17:59:43.166744926 +0100
|
|
|
8178f7 |
@@ -467,6 +467,10 @@ struct lang_hooks
|
|
|
8178f7 |
gimplification. */
|
|
|
8178f7 |
bool deep_unsharing;
|
|
|
8178f7 |
|
|
|
8178f7 |
+ /* Return year of the source language standard version if the FE supports
|
|
|
8178f7 |
+ multiple versions of the standard. */
|
|
|
8178f7 |
+ int (*source_language) (void);
|
|
|
8178f7 |
+
|
|
|
8178f7 |
/* Whenever you add entries here, make sure you adjust langhooks-def.h
|
|
|
8178f7 |
and langhooks.c accordingly. */
|
|
|
8178f7 |
};
|
|
|
8178f7 |
--- gcc/langhooks-def.h.jj 2011-01-03 12:53:05.000000000 +0100
|
|
|
8178f7 |
+++ gcc/langhooks-def.h 2011-01-04 18:00:44.858851030 +0100
|
|
|
8178f7 |
@@ -118,6 +118,7 @@ extern void lhd_omp_firstprivatize_type_
|
|
|
8178f7 |
#define LANG_HOOKS_BLOCK_MAY_FALLTHRU hook_bool_const_tree_true
|
|
|
8178f7 |
#define LANG_HOOKS_EH_USE_CXA_END_CLEANUP false
|
|
|
8178f7 |
#define LANG_HOOKS_DEEP_UNSHARING false
|
|
|
8178f7 |
+#define LANG_HOOKS_SOURCE_LANGUAGE NULL
|
|
|
8178f7 |
|
|
|
8178f7 |
/* Attribute hooks. */
|
|
|
8178f7 |
#define LANG_HOOKS_ATTRIBUTE_TABLE NULL
|
|
|
8178f7 |
@@ -303,7 +304,8 @@ extern void lhd_end_section (void);
|
|
|
8178f7 |
LANG_HOOKS_EH_PROTECT_CLEANUP_ACTIONS, \
|
|
|
8178f7 |
LANG_HOOKS_BLOCK_MAY_FALLTHRU, \
|
|
|
8178f7 |
LANG_HOOKS_EH_USE_CXA_END_CLEANUP, \
|
|
|
8178f7 |
- LANG_HOOKS_DEEP_UNSHARING \
|
|
|
8178f7 |
+ LANG_HOOKS_DEEP_UNSHARING, \
|
|
|
8178f7 |
+ LANG_HOOKS_SOURCE_LANGUAGE \
|
|
|
8178f7 |
}
|
|
|
8178f7 |
|
|
|
8178f7 |
#endif /* GCC_LANG_HOOKS_DEF_H */
|
|
|
8178f7 |
--- gcc/c/c-lang.c.jj 2011-01-03 12:53:05.376056936 +0100
|
|
|
8178f7 |
+++ gcc/c/c-lang.c 2011-01-04 17:59:43.167743798 +0100
|
|
|
8178f7 |
@@ -36,6 +36,12 @@ along with GCC; see the file COPYING3.
|
|
|
8178f7 |
|
|
|
8178f7 |
enum c_language_kind c_language = clk_c;
|
|
|
8178f7 |
|
|
|
8178f7 |
+static int
|
|
|
8178f7 |
+c_source_language (void)
|
|
|
8178f7 |
+{
|
|
|
8178f7 |
+ return flag_isoc99 ? 1999 : 1989;
|
|
|
8178f7 |
+}
|
|
|
8178f7 |
+
|
|
|
8178f7 |
/* Lang hooks common to C and ObjC are declared in c-objc-common.h;
|
|
|
8178f7 |
consequently, there should be very few hooks below. */
|
|
|
8178f7 |
|
|
|
8178f7 |
@@ -45,6 +51,8 @@ enum c_language_kind c_language = clk_c;
|
|
|
8178f7 |
#define LANG_HOOKS_INIT c_objc_common_init
|
|
|
8178f7 |
#undef LANG_HOOKS_INIT_TS
|
|
|
8178f7 |
#define LANG_HOOKS_INIT_TS c_common_init_ts
|
|
|
8178f7 |
+#undef LANG_HOOKS_SOURCE_LANGUAGE
|
|
|
8178f7 |
+#define LANG_HOOKS_SOURCE_LANGUAGE c_source_language
|
|
|
8178f7 |
|
|
|
8178f7 |
/* Each front end provides its own lang hook initializer. */
|
|
|
8178f7 |
struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER;
|
|
|
8178f7 |
--- gcc/dwarf2out.c.jj 2011-01-03 12:53:05.102056475 +0100
|
|
|
8178f7 |
+++ gcc/dwarf2out.c 2011-01-04 18:03:14.534151763 +0100
|
|
|
8178f7 |
@@ -16109,9 +16109,18 @@ add_bit_size_attribute (dw_die_ref die,
|
|
|
8178f7 |
static inline void
|
|
|
8178f7 |
add_prototyped_attribute (dw_die_ref die, tree func_type)
|
|
|
8178f7 |
{
|
|
|
8178f7 |
- if (get_AT_unsigned (comp_unit_die (), DW_AT_language) == DW_LANG_C89
|
|
|
8178f7 |
- && prototype_p (func_type))
|
|
|
8178f7 |
- add_AT_flag (die, DW_AT_prototyped, 1);
|
|
|
8178f7 |
+ switch (get_AT_unsigned (comp_unit_die (), DW_AT_language))
|
|
|
8178f7 |
+ {
|
|
|
8178f7 |
+ case DW_LANG_C:
|
|
|
8178f7 |
+ case DW_LANG_C89:
|
|
|
8178f7 |
+ case DW_LANG_C99:
|
|
|
8178f7 |
+ case DW_LANG_ObjC:
|
|
|
8178f7 |
+ if (prototype_p (func_type))
|
|
|
8178f7 |
+ add_AT_flag (die, DW_AT_prototyped, 1);
|
|
|
8178f7 |
+ break;
|
|
|
8178f7 |
+ default:
|
|
|
8178f7 |
+ break;
|
|
|
8178f7 |
+ }
|
|
|
8178f7 |
}
|
|
|
8178f7 |
|
|
|
8178f7 |
/* Add an 'abstract_origin' attribute below a given DIE. The DIE is found
|
|
|
8178f7 |
@@ -18915,6 +18924,10 @@ gen_compile_unit_die (const char *filena
|
|
|
8178f7 |
if (strcmp (language_string, "GNU Go") == 0)
|
|
|
8178f7 |
language = DW_LANG_Go;
|
|
|
8178f7 |
}
|
|
|
8178f7 |
+ else if (strcmp (language_string, "GNU C") == 0
|
|
|
8178f7 |
+ && lang_hooks.source_language
|
|
|
8178f7 |
+ && lang_hooks.source_language () >= 1999)
|
|
|
8178f7 |
+ language = DW_LANG_C99;
|
|
|
8178f7 |
}
|
|
|
8178f7 |
/* Use a degraded Fortran setting in strict DWARF2 so is_fortran works. */
|
|
|
8178f7 |
else if (strcmp (language_string, "GNU Fortran") == 0)
|