aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Wielaard <mark@klomp.org>2020-08-23 16:21:08 +0200
committerMark Wielaard <mark@klomp.org>2020-09-17 20:13:13 +0200
commit71e3d1970c00a74be16c0f5a3fcaced359077135 (patch)
tree0b8e2531078c897dad1349c83761f85f81b9231c
parentee7aa7e7b9d490c9c929edfd4d4a730df2f0052d (diff)
downloadgcc-71e3d1970c00a74be16c0f5a3fcaced359077135.zip
gcc-71e3d1970c00a74be16c0f5a3fcaced359077135.tar.gz
gcc-71e3d1970c00a74be16c0f5a3fcaced359077135.tar.bz2
Add DWARF5 variants of assembly scan tests that use DW_FORM_implicit_const
Some DWARF tests scan the assembly output looking for constant values. When using DWARF5 those constants might use DW_FORM_implicit_const, which are output (in the comments) after the attribute instead of before. To make sure these tests work introduce a -gdwarf-5 variant of these tests and explicitly use -gdwarf-2 for the original. gcc/testsuite/ChangeLog: * gcc.dg/debug/dwarf2/inline2.c: Add -gdwarf-2. * g++.dg/debug/dwarf2/inline-var-1.C: Likewise. * gcc.dg/debug/dwarf2/pr41445-5.c: Likewise. * gcc.dg/debug/dwarf2/pr41445-6.c: Likewise. * gcc.dg/debug/dwarf2/inline6.c: New variant with -gdwarf-5. * g++.dg/debug/dwarf2/inline-var-3.C: Likewise. * gcc.dg/debug/dwarf2/pr41445-7.c: Likewise. * gcc.dg/debug/dwarf2/pr41445-8.c: Likewise.
-rw-r--r--gcc/testsuite/g++.dg/debug/dwarf2/inline-var-1.C2
-rw-r--r--gcc/testsuite/g++.dg/debug/dwarf2/inline-var-3.C29
-rw-r--r--gcc/testsuite/gcc.dg/debug/dwarf2/inline2.c4
-rw-r--r--gcc/testsuite/gcc.dg/debug/dwarf2/inline6.c69
-rw-r--r--gcc/testsuite/gcc.dg/debug/dwarf2/pr41445-5.c2
-rw-r--r--gcc/testsuite/gcc.dg/debug/dwarf2/pr41445-6.c2
-rw-r--r--gcc/testsuite/gcc.dg/debug/dwarf2/pr41445-7.c16
-rw-r--r--gcc/testsuite/gcc.dg/debug/dwarf2/pr41445-8.c11
8 files changed, 131 insertions, 4 deletions
diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/inline-var-1.C b/gcc/testsuite/g++.dg/debug/dwarf2/inline-var-1.C
index 3b1c913..9a88e28 100644
--- a/gcc/testsuite/g++.dg/debug/dwarf2/inline-var-1.C
+++ b/gcc/testsuite/g++.dg/debug/dwarf2/inline-var-1.C
@@ -1,5 +1,5 @@
// { dg-do compile { target c++17 } }
-// { dg-options "-O -g -dA -gno-strict-dwarf -fno-eliminate-unused-debug-symbols" }
+// { dg-options "-O -gdwarf-2 -dA -gno-strict-dwarf -fno-eliminate-unused-debug-symbols" }
// { dg-require-weak "" }
// { dg-final { scan-assembler-times "0x3\[^\n\r]* DW_AT_inline" 6 { xfail *-*-aix* } } }
// { dg-final { scan-assembler-times "0x1\[^\n\r]* DW_AT_inline" 2 { xfail *-*-aix* } } }
diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/inline-var-3.C b/gcc/testsuite/g++.dg/debug/dwarf2/inline-var-3.C
new file mode 100644
index 0000000..52ed5b6
--- /dev/null
+++ b/gcc/testsuite/g++.dg/debug/dwarf2/inline-var-3.C
@@ -0,0 +1,29 @@
+// DWARF5 variant of inline-var-1.C
+// { dg-do compile { target c++17 } }
+// { dg-options "-O -gdwarf-5 -dA -gno-strict-dwarf -fno-eliminate-unused-debug-symbols" }
+// { dg-require-weak "" }
+// { dg-final { scan-assembler-times " DW_AT_inline \\(0x3\\)" 2 { xfail *-*-aix* } } }
+// { dg-final { scan-assembler-times "0x3\[^\n\r]* DW_AT_inline" 4 { xfail *-*-aix* } } }
+// { dg-final { scan-assembler-times "0x1\[^\n\r]* DW_AT_inline" 2 { xfail *-*-aix* } } }
+// { dg-final { scan-assembler-times " DW_AT_declaration" 6 { xfail *-*-aix* } } }
+// { dg-final { scan-assembler-times " DW_AT_specification" 6 { xfail *-*-aix* } } }
+// { dg-final { scan-assembler-times " DW_AT_\[^\n\r]*linkage_name" 7 { xfail *-*-aix* } } }
+
+inline int a;
+struct S
+{
+ static inline double b = 4.0;
+ static constexpr int c = 2;
+ static constexpr inline char d = 3;
+} s;
+template <int N>
+inline int e = N;
+int &f = e<2>;
+template <int N>
+struct T
+{
+ static inline double g = 4.0;
+ static constexpr int h = 2;
+ static inline constexpr char i = 3;
+};
+T<5> t;
diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/inline2.c b/gcc/testsuite/gcc.dg/debug/dwarf2/inline2.c
index 7e019a6..9c36450 100644
--- a/gcc/testsuite/gcc.dg/debug/dwarf2/inline2.c
+++ b/gcc/testsuite/gcc.dg/debug/dwarf2/inline2.c
@@ -14,7 +14,9 @@
properly nested DW_TAG_inlined_subroutine DIEs for third, second and first.
*/
-/* { dg-options "-O -g3 -gdwarf -dA -fgnu89-inline" } */
+/* Explicitly use dwarf-2 because dwarf-5 might use DW_FORM_implicit_const
+ which is hard to scan for. */
+/* { dg-options "-O -g3 -gdwarf-2 -dA -fgnu89-inline" } */
/* { dg-do compile } */
/* There are 6 inlined subroutines:
diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/inline6.c b/gcc/testsuite/gcc.dg/debug/dwarf2/inline6.c
new file mode 100644
index 0000000..03013f1
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/dwarf2/inline6.c
@@ -0,0 +1,69 @@
+/* DWARF5 variant of inline2.
+ Origin: PR debug/37801
+
+ Abstract instances (DW_TAG_subroutines having the DW_AT_inline attribute)
+ of second and first were having a DW_TAG_lexical_block DIE wrongly
+ representing the inlined calls to third (in second) and to
+ second (in first). At the same time, main didn't have children
+ DW_TAG_inlined_subroutine DIEs representing the inlined calls to
+ first, second and third.
+
+ The ideal goal here is to test that we have no superfluous
+ DW_TAG_lexical_block DIE anymore, that abstract instances DIEs have
+ no descendant DIE with a DW_AT_abstract_origin attribute, and that main has
+ properly nested DW_TAG_inlined_subroutine DIEs for third, second and first.
+*/
+
+/* Explicitly use dwarf-5 which uses DW_FORM_implicit_const. */
+/* { dg-options "-O -g3 -gdwarf-5 -dA -fgnu89-inline" } */
+/* { dg-do compile } */
+
+/* There are 6 inlined subroutines:
+ - One for each subroutine inlined into main, that's 3.
+ - One for earch subroutine inline into the out of line instances
+ of third, second and first. */
+/* { dg-final { scan-assembler-times "\\(DIE \\(\[^\n\]*\\) DW_TAG_inlined_subroutine" 6 } } */
+
+/* We should have no DW_TAG_lexical_block DIEs, all inline instances
+ should have the first subblock elided to match the abstract instance
+ layout. */
+/* { dg-final { scan-assembler-times "\\(DIE \\(\[^\n\]*\\) DW_TAG_lexical_block" 0 } } */
+
+
+/* There are 3 DW_AT_inline attributes: one per abstract inline instance.
+ The value of the attribute must be 0x3, meaning the function was
+ actually inlined. */
+/* { dg-final { scan-assembler-times " DW_AT_inline \\(0x3\\)" 3 } } */
+
+volatile int *a;
+
+inline void
+third (int arg3)
+{
+ int var3 = arg3;
+ a[0] = var3;
+}
+
+inline void
+second (int arg2)
+{
+ int var2 = arg2;
+ third (var2+1);
+}
+
+inline void
+first (int arg1)
+{
+ int var1 = arg1;
+ second (var1+1);
+}
+
+int
+main ()
+{
+ int some_int = 1;
+ first (some_int);
+ return 0;
+}
+
+
diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/pr41445-5.c b/gcc/testsuite/gcc.dg/debug/dwarf2/pr41445-5.c
index d646f59..80300ec 100644
--- a/gcc/testsuite/gcc.dg/debug/dwarf2/pr41445-5.c
+++ b/gcc/testsuite/gcc.dg/debug/dwarf2/pr41445-5.c
@@ -2,7 +2,7 @@
/* Test that token after multi-line function-like macro use
gets correct locus even when preprocessing separately. */
/* { dg-do compile } */
-/* { dg-options "-save-temps -gdwarf -O0 -dA -fno-merge-debug-strings" } */
+/* { dg-options "-save-temps -gdwarf-2 -O0 -dA -fno-merge-debug-strings" } */
#define A(x) vari x
#define vari(x)
diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/pr41445-6.c b/gcc/testsuite/gcc.dg/debug/dwarf2/pr41445-6.c
index 340cb38..fbf0337 100644
--- a/gcc/testsuite/gcc.dg/debug/dwarf2/pr41445-6.c
+++ b/gcc/testsuite/gcc.dg/debug/dwarf2/pr41445-6.c
@@ -1,6 +1,6 @@
/* PR preprocessor/41445 */
/* { dg-do compile } */
-/* { dg-options "-gdwarf -O0 -dA -fno-merge-debug-strings" } */
+/* { dg-options "-gdwarf-2 -O0 -dA -fno-merge-debug-strings" } */
#include "pr41445-5.c"
diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/pr41445-7.c b/gcc/testsuite/gcc.dg/debug/dwarf2/pr41445-7.c
new file mode 100644
index 0000000..0e0de82
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/dwarf2/pr41445-7.c
@@ -0,0 +1,16 @@
+/* PR preprocessor/41445 DWARF5 variant */
+/* Test that token after multi-line function-like macro use
+ gets correct locus even when preprocessing separately. */
+/* { dg-do compile } */
+/* { dg-options "-save-temps -gdwarf-5 -O0 -dA -fno-merge-debug-strings" } */
+
+#define A(x) vari x
+#define vari(x)
+#define B , varj
+int A(B) ;
+
+/* We want to check that both vari and varj have the same line
+ number. */
+
+/* { dg-final { scan-assembler "DW_TAG_variable\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*\"vari\[^\\r\\n\]*DW_AT_name(\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*DW_AT_)*\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*\[^\\r\\n\]*DW_AT_decl_line \\((0xa|10)\\)" } } */
+/* { dg-final { scan-assembler "DW_TAG_variable\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*\"varj\[^\\r\\n\]*DW_AT_name(\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*DW_AT_)*\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*\[^\\r\\n\]*DW_AT_decl_line \\((0xa|10)\\)" } } */
diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/pr41445-8.c b/gcc/testsuite/gcc.dg/debug/dwarf2/pr41445-8.c
new file mode 100644
index 0000000..3a6eeb5
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/dwarf2/pr41445-8.c
@@ -0,0 +1,11 @@
+/* PR preprocessor/41445 DWARF5 variant*/
+/* { dg-do compile } */
+/* { dg-options "-gdwarf-5 -O0 -dA -fno-merge-debug-strings" } */
+
+#include "pr41445-5.c"
+
+/* We want to check that both vari and varj have the same line
+ number. */
+
+/* { dg-final { scan-assembler "DW_TAG_variable\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*\"vari\[^\\r\\n\]*DW_AT_name(\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*DW_AT_)*\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*\[^\\r\\n\]*DW_AT_decl_line \\((0xa|10)\\)" } } */
+/* { dg-final { scan-assembler "DW_TAG_variable\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*\"varj\[^\\r\\n\]*DW_AT_name(\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*DW_AT_)*\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*\[^\\r\\n\]*DW_AT_decl_line \\((0xa|10)\\)" } } */