Re: [PATCH 1/2] PR debug/38757 gcc does not emit DW_LANG_C99.
On Fri, Nov 21, 2014 at 8:56 AM, Jakub Jelinek ja...@redhat.com wrote: On Thu, Nov 20, 2014 at 11:30:11PM +0100, Mark Wielaard wrote: --- a/gcc/config/avr/avr-c.c +++ b/gcc/config/avr/avr-c.c @@ -386,7 +386,8 @@ avr_cpu_cpp_builtins (struct cpp_reader *pfile) (as mentioned in ISO/IEC DTR 18037; Annex F.2) which is not implemented in GCC up to now. */ - if (!strcmp (lang_hooks.name, GNU C)) + if (strncmp (lang_hooks.name, GNU C, 5) == 0 + strncmp (lang_hooks.name, GNU C++, 7) != 0) I wonder if the tests for C language shouldn't be better done as (strncmp (lang_hooks.name, GNU C, 5) == 0 strchr (0123456789, lang_hooks.name[5]) != NULL) or (strncmp (lang_hooks.name, GNU C, 5) == 0 (ISDIGIT (lang_hooks.name[5]) || lang_hooks.name[5] == '\0')) to make it explicit what we are looking for, not what we aren't. Or even make that a helper function in langhooks.[ch] lang_GNU_C (), lang_GNU_CXX () + either, so for now use 0. Match GNU C++ first, since it needs to + be compared with strncmp, like GNU C, which has the same prefix. */ + if (! strncmp (language_string, GNU C++, 7) +|| ! strcmp (language_string, GNU Objective-C++)) Wrong formatting, || should be below ! on the previous line. + i = 9; + else if (! strncmp (language_string, GNU C, 5) || ! strcmp (language_string, GNU GIMPLE) || ! strcmp (language_string, GNU Go)) And here too. But if you use a different check for C (see above), you could avoid moving the C++ case first. --- a/gcc/langhooks.h +++ b/gcc/langhooks.h @@ -261,7 +261,8 @@ struct lang_hooks_for_lto struct lang_hooks { - /* String identifying the front end. e.g. GNU C++. */ + /* String identifying the front end. e.g. GNU C++. + Might include language version being used. */ As we no longer have GNU C++ as any name, using it as an example is weird. So, /* String identifying the front end and optionally language standard version, e.g. GNU C++98 or GNU Java. */ ? LGTM otherwise. Yes, otherwise looks good. Thanks, Richard. Jakub
Re: [PATCH 1/2] PR debug/38757 gcc does not emit DW_LANG_C99.
On Fri, 2014-11-21 at 12:48 +0100, Richard Biener wrote: On Fri, Nov 21, 2014 at 8:56 AM, Jakub Jelinek ja...@redhat.com wrote: On Thu, Nov 20, 2014 at 11:30:11PM +0100, Mark Wielaard wrote: --- a/gcc/config/avr/avr-c.c +++ b/gcc/config/avr/avr-c.c @@ -386,7 +386,8 @@ avr_cpu_cpp_builtins (struct cpp_reader *pfile) (as mentioned in ISO/IEC DTR 18037; Annex F.2) which is not implemented in GCC up to now. */ - if (!strcmp (lang_hooks.name, GNU C)) + if (strncmp (lang_hooks.name, GNU C, 5) == 0 + strncmp (lang_hooks.name, GNU C++, 7) != 0) I wonder if the tests for C language shouldn't be better done as (strncmp (lang_hooks.name, GNU C, 5) == 0 strchr (0123456789, lang_hooks.name[5]) != NULL) or (strncmp (lang_hooks.name, GNU C, 5) == 0 (ISDIGIT (lang_hooks.name[5]) || lang_hooks.name[5] == '\0')) to make it explicit what we are looking for, not what we aren't. Or even make that a helper function in langhooks.[ch] lang_GNU_C (), lang_GNU_CXX () Nice idea. I added those. It also fixes the formatting issues and makes the diff smaller. --- a/gcc/langhooks.h +++ b/gcc/langhooks.h @@ -261,7 +261,8 @@ struct lang_hooks_for_lto struct lang_hooks { - /* String identifying the front end. e.g. GNU C++. */ + /* String identifying the front end. e.g. GNU C++. + Might include language version being used. */ As we no longer have GNU C++ as any name, using it as an example is weird. So, /* String identifying the front end and optionally language standard version, e.g. GNU C++98 or GNU Java. */ ? Used Jakub's example text. OK to push? Thanks, Mark 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. diff --git a/gcc/c-family/c-opts.c b/gcc/c-family/c-opts.c index 000fdd2..08a36f0 100644 --- a/gcc/c-family/c-opts.c +++ b/gcc/c-family/c-opts.c @@ -1450,6 +1450,7 @@ set_std_c89 (int c94, int iso) flag_isoc94 = c94; flag_isoc99 = 0; flag_isoc11 = 0; + lang_hooks.name = GNU C89; } /* Set the C 99 standard (without GNU extensions if ISO). */ @@ -1463,6 +1464,7 @@ set_std_c99 (int iso) flag_isoc11 = 0; flag_isoc99 = 1; flag_isoc94 = 1; + lang_hooks.name = GNU C99; } /* Set the C 11 standard (without GNU extensions if ISO). */ @@ -1476,6 +1478,7 @@ set_std_c11 (int iso) flag_isoc11 = 1; flag_isoc99 = 1; flag_isoc94 = 1; + lang_hooks.name = GNU C11; } /* Set the C++ 98 standard (without GNU extensions if ISO). */ @@ -1487,6 +1490,7 @@ set_std_cxx98 (int iso) flag_no_nonansi_builtin = iso; flag_iso = iso; cxx_dialect = cxx98; + lang_hooks.name = GNU C++98; } /* Set the C++ 2011 standard (without GNU extensions if ISO). */ @@ -1501,6 +1505,7 @@ set_std_cxx11 (int iso)
Re: [PATCH 1/2] PR debug/38757 gcc does not emit DW_LANG_C99.
On Fri, Nov 21, 2014 at 02:01:55PM +0100, Mark Wielaard wrote: 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. Ok, thanks. Jakub
[PATCH 1/2] PR debug/38757 gcc does not emit DW_LANG_C99.
On Thu, Nov 13, 2014 at 02:19:57PM +0100, Richard Biener wrote: I'm fine with the string solution as well. Just properly transfer whatever info you want through the translation unit decl and LTO stream it. OK, strings it is then. Here are two patches. The first makes the change to the lang_hook.name to include the std version for GNU C and GNU C++ and updates all users. It merges the TRANSLATION_UNIT_LANGUAGE in dwarf2out.c It uses this to set DW_LANG_C99 when appropriate. The second patch adds support for C11, C++11 and C++14 as outlined in the DWARFv5 DRAFT http://dwarfstd.org/doc/dwarf5.20141029.pdf Note that this does not add DW_LANG_C_plus_plus_03 which I believe is a mistake: http://thread.gmane.org/gmane.comp.standards.dwarf/218 C++03 isn't actually a new language standard, just C++98 plus some new DRs, but no actual language changes. The first patch adds two new tests, which PASS and has no regressions. The second patch adds four new tests, which PASS, but break the C++ prettyprinters. You need a simple patch to GDB to get them working again (just add the new dwarf2.h and use the new constants). It might be better to wait with the second patch till I have patched GDB/binutils, elfutils and valgrind to accept the new values. I'll submit those ASAP. OK to commit the first patch now and the second patch as soon as my patches to GDB/binutils, elfutils and valgrind are accepted upstream? Thanks, Mark --- For C and C++ add the language standard version in use to lang_hooks.name. Change users of lang_hook.name to check with strncmp first for GNU C++ then for GNU C. 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 2014-11-20 Mark Wielaard m...@redhat.com 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 2014-11-20 Mark Wielaard m...@redhat.com PR debug/38757 * config/avr/avr-c.c (avr_cpu_cpp_builtins): Use strncmp to check lang_hooks.name. * config/darwin.c (darwin_file_end): Likewise. (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 lang_hooks.name to determine if DW_LANG_C99 or DW_LANG_C89 should be returned. * fold-const.c (fold_cond_expr_with_comparison): Use strncmp to check lang_hooks.name. * langhooks.h (struct lang_hooks): Add version comment to name. * vmsdbgout.c (vmsdbgout_init): Use strncmp to check lang_hooks.name. --- gcc/ChangeLog| 26 ++ gcc/c-family/ChangeLog | 11 ++ gcc/c-family/c-opts.c| 7 gcc/config/avr/avr-c.c | 3 +- gcc/config/darwin.c | 4 +-- gcc/config/ia64/ia64.c | 2 +- gcc/config/rs6000/rs6000.c | 11 +++--- gcc/dbxout.c | 10 +++--- gcc/dwarf2out.c | 53 gcc/fold-const.c | 2 +- gcc/langhooks.h | 3 +- gcc/testsuite/ChangeLog | 6 gcc/testsuite/gcc.dg/debug/dwarf2/lang-c89.c | 6 gcc/testsuite/gcc.dg/debug/dwarf2/lang-c99.c | 6 gcc/vmsdbgout.c | 6 ++-- 15 files changed, 131 insertions(+), 25 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/debug/dwarf2/lang-c89.c create mode 100644 gcc/testsuite/gcc.dg/debug/dwarf2/lang-c99.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 428725b..222558d 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,29 @@ +2014-11-20 Mark Wielaard m...@redhat.com + + PR debug/38757 + * config/avr/avr-c.c (avr_cpu_cpp_builtins): Use strncmp to + check lang_hooks.name. + * config/darwin.c (darwin_file_end): Likewise. + (darwin_override_options): Likewise. + * config/ia64/ia64.c (ia64_struct_retval_addr_is_first_parm_p): + Likewise. + *
Re: [PATCH 1/2] PR debug/38757 gcc does not emit DW_LANG_C99.
On Thu, Nov 20, 2014 at 11:30:11PM +0100, Mark Wielaard wrote: --- a/gcc/config/avr/avr-c.c +++ b/gcc/config/avr/avr-c.c @@ -386,7 +386,8 @@ avr_cpu_cpp_builtins (struct cpp_reader *pfile) (as mentioned in ISO/IEC DTR 18037; Annex F.2) which is not implemented in GCC up to now. */ - if (!strcmp (lang_hooks.name, GNU C)) + if (strncmp (lang_hooks.name, GNU C, 5) == 0 + strncmp (lang_hooks.name, GNU C++, 7) != 0) I wonder if the tests for C language shouldn't be better done as (strncmp (lang_hooks.name, GNU C, 5) == 0 strchr (0123456789, lang_hooks.name[5]) != NULL) or (strncmp (lang_hooks.name, GNU C, 5) == 0 (ISDIGIT (lang_hooks.name[5]) || lang_hooks.name[5] == '\0')) to make it explicit what we are looking for, not what we aren't. + either, so for now use 0. Match GNU C++ first, since it needs to + be compared with strncmp, like GNU C, which has the same prefix. */ + if (! strncmp (language_string, GNU C++, 7) +|| ! strcmp (language_string, GNU Objective-C++)) Wrong formatting, || should be below ! on the previous line. + i = 9; + else if (! strncmp (language_string, GNU C, 5) || ! strcmp (language_string, GNU GIMPLE) || ! strcmp (language_string, GNU Go)) And here too. But if you use a different check for C (see above), you could avoid moving the C++ case first. --- a/gcc/langhooks.h +++ b/gcc/langhooks.h @@ -261,7 +261,8 @@ struct lang_hooks_for_lto struct lang_hooks { - /* String identifying the front end. e.g. GNU C++. */ + /* String identifying the front end. e.g. GNU C++. + Might include language version being used. */ As we no longer have GNU C++ as any name, using it as an example is weird. So, /* String identifying the front end and optionally language standard version, e.g. GNU C++98 or GNU Java. */ ? LGTM otherwise. Jakub