c++, debug: Treat -std=c++20 -gdwarf-5 like C++14 rather than C++98
authorJakub Jelinek <jakub@redhat.com>
Tue, 1 Dec 2020 08:41:16 +0000 (09:41 +0100)
committerJakub Jelinek <jakub@redhat.com>
Tue, 1 Dec 2020 08:41:16 +0000 (09:41 +0100)
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  <jakub@redhat.com>

* 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
gcc/testsuite/g++.dg/debug/dwarf2/lang-cpp17.C [new file with mode: 0644]
gcc/testsuite/g++.dg/debug/dwarf2/lang-cpp20.C [new file with mode: 0644]

index bfe2d637e3fed132019a1358a535132e2520cb16..0a0a7ead2eae547c841fa8d31b21a1ddcd3429ed 100644 (file)
@@ -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 (file)
index 0000000..460294c
--- /dev/null
@@ -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 (file)
index 0000000..abd7351
--- /dev/null
@@ -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;