diff mbox series

c++, debug: Treat -std=c++20 -gdwarf-5 like C++14 rather than C++98

Message ID 20201130141144.GJ3788@tucnak
State New
Headers show
Series c++, debug: Treat -std=c++20 -gdwarf-5 like C++14 rather than C++98 | expand

Commit Message

Jakub Jelinek Nov. 30, 2020, 2:11 p.m. UTC
Hi!

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.

Ok for trunk if it passes bootstrap/regtest?

2020-11-30  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.


	Jakub

Comments

Richard Biener Nov. 30, 2020, 2:24 p.m. UTC | #1
On Mon, Nov 30, 2020 at 3:12 PM Jakub Jelinek via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
> Hi!
>
> 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.
>
> Ok for trunk if it passes bootstrap/regtest?

OK.

> 2020-11-30  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.jj  2020-11-26 16:22:29.111352844 +0100
> +++ gcc/dwarf2out.c     2020-11-30 15:05:52.601317310 +0100
> @@ -24646,7 +24646,8 @@ gen_compile_unit_die (const char *filena
>             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;
>         }
> --- gcc/testsuite/g++.dg/debug/dwarf2/lang-cpp17.C.jj   2020-11-30 15:06:35.631836747 +0100
> +++ gcc/testsuite/g++.dg/debug/dwarf2/lang-cpp17.C      2020-11-30 15:07:19.160350623 +0100
> @@ -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;
> --- gcc/testsuite/g++.dg/debug/dwarf2/lang-cpp20.C.jj   2020-11-30 15:07:27.436258201 +0100
> +++ gcc/testsuite/g++.dg/debug/dwarf2/lang-cpp20.C      2020-11-30 15:07:37.801142442 +0100
> @@ -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;
>
>         Jakub
>
diff mbox series

Patch

--- gcc/dwarf2out.c.jj	2020-11-26 16:22:29.111352844 +0100
+++ gcc/dwarf2out.c	2020-11-30 15:05:52.601317310 +0100
@@ -24646,7 +24646,8 @@  gen_compile_unit_die (const char *filena
 	    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;
 	}
--- gcc/testsuite/g++.dg/debug/dwarf2/lang-cpp17.C.jj	2020-11-30 15:06:35.631836747 +0100
+++ gcc/testsuite/g++.dg/debug/dwarf2/lang-cpp17.C	2020-11-30 15:07:19.160350623 +0100
@@ -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;
--- gcc/testsuite/g++.dg/debug/dwarf2/lang-cpp20.C.jj	2020-11-30 15:07:27.436258201 +0100
+++ gcc/testsuite/g++.dg/debug/dwarf2/lang-cpp20.C	2020-11-30 15:07:37.801142442 +0100
@@ -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;