From dcc9706615ef48df3c0bfa8a44b29bba52563f3e Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Fri, 21 Nov 2014 16:00:06 +0000 Subject: PR debug/38757 gcc does not emit DW_LANG_C99. For C and C++ add the language standard version in use to lang_hooks.name. Change users of lang_hook.name to check with new functions lang_GNU_C or lang_GNU_CXX. In dwarf2out.c output the DW_LANG_C version from the lang_hooks.name and merge any LTO TRANSLATION_UNIT_LANGUAGE found. Adds two testcases to dwarf2.exp to check the right DWARF DW_AT_language is set on the compile_unit depending on the -std=c89 or -std=c99 setting. gcc/c-family/ChangeLog PR debug/38757 * c-opts.c (set_std_c89): Set lang_hooks.name. (set_std_c99): Likewise. (set_std_c11): Likewise. (set_std_cxx98): Likewise. (set_std_cxx11): Likewise. (set_std_cxx14): Likewise. (set_std_cxx1z): Likewise. gcc/ChangeLog PR debug/38757 * config/avr/avr-c.c (avr_cpu_cpp_builtins): Use lang_GNU_C. * config/darwin.c (darwin_file_end): Use lang_GNU_CXX. (darwin_override_options): Likewise. * config/ia64/ia64.c (ia64_struct_retval_addr_is_first_parm_p): Likewise. * config/rs6000/rs6000.c (rs6000_output_function_epilogue): Likewise. * dbxout.c (get_lang_number): Likewise. (dbxout_type): Likewise. (dbxout_symbol_location): Likewise. * dwarf2out.c (add_prototyped_attribute): Add DW_AT_prototype also for DW_LANG_{C,C99,ObjC}. (highest_c_language): New function. (gen_compile_unit_die): Call highest_c_language to merge LTO TRANSLATION_UNIT_LANGUAGE. Use strncmp language_string to determine if DW_LANG_C99 or DW_LANG_C89 should be returned. * fold-const.c (fold_cond_expr_with_comparison): Use lang_GNU_CXX. * langhooks.h (struct lang_hooks): Add version comment to name. (lang_GNU_C): New function declaration. (lang_GNU_CXX): Likewise. * langhooks.c (lang_GNU_C): New function. (lang_GNU_CXX): Likewise. * vmsdbgout.c (vmsdbgout_init): Use lang_GNU_C and lang_GNU_CXX. gcc/testsuite/ChangeLog PR debug/38757 * gcc.dg/debug/dwarf2/lang-c89.c: New test. * gcc.dg/debug/dwarf2/lang-c99.c: Likewise. From-SVN: r217934 --- gcc/dbxout.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'gcc/dbxout.c') diff --git a/gcc/dbxout.c b/gcc/dbxout.c index aa15a39..1f04f72 100644 --- a/gcc/dbxout.c +++ b/gcc/dbxout.c @@ -946,10 +946,9 @@ static unsigned int ATTRIBUTE_UNUSED get_lang_number (void) { const char *language_string = lang_hooks.name; - - if (strcmp (language_string, "GNU C") == 0) + if (lang_GNU_C ()) return N_SO_C; - else if (strcmp (language_string, "GNU C++") == 0) + else if (lang_GNU_CXX ()) return N_SO_CC; else if (strcmp (language_string, "GNU F77") == 0) return N_SO_FORTRAN; @@ -2167,7 +2166,7 @@ dbxout_type (tree type, int full) access == access_protected_node ? '1' :'0'); if (BINFO_VIRTUAL_P (child) - && (strcmp (lang_hooks.name, "GNU C++") == 0 + && (lang_GNU_CXX () || strcmp (lang_hooks.name, "GNU Objective-C++") == 0)) /* For a virtual base, print the (negative) offset within the vtable where we must look @@ -3028,7 +3027,7 @@ dbxout_symbol_location (tree decl, tree type, const char *suffix, rtx home) we rely on the fact that error_mark_node initializers always end up in bss for C++ and never end up in bss for C. */ if (DECL_INITIAL (decl) == 0 - || (!strcmp (lang_hooks.name, "GNU C++") + || (lang_GNU_CXX () && DECL_INITIAL (decl) == error_mark_node)) { int offs; -- cgit v1.1