From a90606ab979762ce4630777c2fce5c921d0a2b96 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Tue, 1 Dec 2020 09:41:16 +0100 Subject: [PATCH] c++, debug: Treat -std=c++20 -gdwarf-5 like C++14 rather than C++98 I have noticed that while we use DW_LANG_C_plus_plus_14 for -std=c++17 -gdwarf-5, we use DW_LANG_C_plus_plus (aka C++98) for -std=c++20 -gdwarf-5. The following patch makes those two match. 2020-12-01 Jakub Jelinek * dwarf2out.c (gen_compile_unit_die): Treat GNU C++20 like C++14 for -gdwarf-5. * g++.dg/debug/dwarf2/lang-cpp17.C: New test. * g++.dg/debug/dwarf2/lang-cpp20.C: New test. --- gcc/dwarf2out.c | 3 ++- gcc/testsuite/g++.dg/debug/dwarf2/lang-cpp17.C | 7 +++++++ gcc/testsuite/g++.dg/debug/dwarf2/lang-cpp20.C | 7 +++++++ 3 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/debug/dwarf2/lang-cpp17.C create mode 100644 gcc/testsuite/g++.dg/debug/dwarf2/lang-cpp20.C diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index bfe2d637e3f..0a0a7ead2ea 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -24646,7 +24646,8 @@ gen_compile_unit_die (const char *filename) language = DW_LANG_C_plus_plus_11; else if (strcmp (language_string, "GNU C++14") == 0) language = DW_LANG_C_plus_plus_14; - else if (strcmp (language_string, "GNU C++17") == 0) + else if (strcmp (language_string, "GNU C++17") == 0 + || strcmp (language_string, "GNU C++20") == 0) /* For now. */ language = DW_LANG_C_plus_plus_14; } diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/lang-cpp17.C b/gcc/testsuite/g++.dg/debug/dwarf2/lang-cpp17.C new file mode 100644 index 00000000000..460294ca27d --- /dev/null +++ b/gcc/testsuite/g++.dg/debug/dwarf2/lang-cpp17.C @@ -0,0 +1,7 @@ +// { dg-do compile } +// { dg-options "-O -std=c++17 -gdwarf-5 -dA" } +// For -gdwarf-6 hopefully DW_LANG_C_plus_plus_17 +// DW_LANG_C_plus_plus_14 = 0x0021 +// { dg-final { scan-assembler "0x21\[^\n\r]* DW_AT_language" } } */ + +int version; diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/lang-cpp20.C b/gcc/testsuite/g++.dg/debug/dwarf2/lang-cpp20.C new file mode 100644 index 00000000000..abd7351e4de --- /dev/null +++ b/gcc/testsuite/g++.dg/debug/dwarf2/lang-cpp20.C @@ -0,0 +1,7 @@ +// { dg-do compile } +// { dg-options "-O -std=c++20 -gdwarf-5 -dA" } +// For -gdwarf-6 hopefully DW_LANG_C_plus_plus_20 +// DW_LANG_C_plus_plus_14 = 0x0021 +// { dg-final { scan-assembler "0x21\[^\n\r]* DW_AT_language" } } */ + +int version; -- 2.30.2