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.
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;
}
--- /dev/null
+// { 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;
--- /dev/null
+// { 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;