dwarf2out.c (tree_add_const_value_attribute): For INTEGER_CST that fits into uhwi...
authorJakub Jelinek <jakub@redhat.com>
Wed, 20 Sep 2017 09:04:22 +0000 (11:04 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Wed, 20 Sep 2017 09:04:22 +0000 (11:04 +0200)
* dwarf2out.c (tree_add_const_value_attribute): For INTEGER_CST
that fits into uhwi or shwi, add DW_AT_const_value regardless
of early_dwarf without going through RTL, using add_AT_unsigned
or add_AT_int.

* g++.dg/debug/dwarf2/template-params-13.C: New test.
* g++.dg/debug/dwarf2/template-params-5.C: Adjust regexps so that
it doesn't match newlines.
* g++.dg/debug/dwarf2/template-params-3.C: Likewise.
* g++.dg/debug/dwarf2/template-func-params-3.C: Likewise.
* g++.dg/debug/dwarf2/lang-cpp98.C: Likewise.
* g++.dg/debug/dwarf2/template-func-params-2.C: Likewise.
* g++.dg/debug/dwarf2/template-func-params-1.C: Likewise.
* g++.dg/debug/dwarf2/template-func-params-5.C: Likewise.
* g++.dg/debug/dwarf2/template-params-1.C: Likewise.
* g++.dg/debug/dwarf2/template-params-2.C: Likewise.
* g++.dg/debug/dwarf2/lang-cpp14.C: Likewise.
* g++.dg/debug/dwarf2/lang-cpp11.C: Likewise.

From-SVN: r253004

15 files changed:
gcc/ChangeLog
gcc/dwarf2out.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/debug/dwarf2/lang-cpp11.C
gcc/testsuite/g++.dg/debug/dwarf2/lang-cpp14.C
gcc/testsuite/g++.dg/debug/dwarf2/lang-cpp98.C
gcc/testsuite/g++.dg/debug/dwarf2/template-func-params-1.C
gcc/testsuite/g++.dg/debug/dwarf2/template-func-params-2.C
gcc/testsuite/g++.dg/debug/dwarf2/template-func-params-3.C
gcc/testsuite/g++.dg/debug/dwarf2/template-func-params-5.C
gcc/testsuite/g++.dg/debug/dwarf2/template-params-1.C
gcc/testsuite/g++.dg/debug/dwarf2/template-params-13.C [new file with mode: 0644]
gcc/testsuite/g++.dg/debug/dwarf2/template-params-2.C
gcc/testsuite/g++.dg/debug/dwarf2/template-params-3.C
gcc/testsuite/g++.dg/debug/dwarf2/template-params-5.C

index f620568e85ea5aa7a89b10da3b6c40f2404c1862..b82df9f61add084ceb73d8c4bd8d6f293b540c02 100644 (file)
@@ -1,5 +1,10 @@
 2017-09-20  Jakub Jelinek  <jakub@redhat.com>
 
+       * dwarf2out.c (tree_add_const_value_attribute): For INTEGER_CST
+       that fits into uhwi or shwi, add DW_AT_const_value regardless
+       of early_dwarf without going through RTL, using add_AT_unsigned
+       or add_AT_int.
+
        * dwarf2out.c (DEBUG_LTO_DWO_INFO_SECTION): Reorder defines.
        (DEBUG_LTO_ABBREV_SECTION): Likewise.
        (DEBUG_LTO_MACINFO_SECTION): Likewise.
index d757d2d455382d2bf0a98d35401c31dd735e54bf..eed3a40c422143a02f9ff2162c79fe6a4d0b7ad4 100644 (file)
@@ -19446,6 +19446,19 @@ tree_add_const_value_attribute (dw_die_ref die, tree t)
   init = t;
   gcc_assert (!DECL_P (init));
 
+  if (TREE_CODE (init) == INTEGER_CST)
+    {
+      if (tree_fits_uhwi_p (init))
+       {
+         add_AT_unsigned (die, DW_AT_const_value, tree_to_uhwi (init));
+         return true;
+       }
+      if (tree_fits_shwi_p (init))
+       {
+         add_AT_int (die, DW_AT_const_value, tree_to_shwi (init));
+         return true;
+       }
+    }
   if (! early_dwarf)
     {
       rtl = rtl_for_decl_init (init, type);
index d0cea296d6ae66aec0d9c80a750e702600431abd..0247ada60f4563495f6105c8c028d861e4042495 100644 (file)
@@ -1,3 +1,19 @@
+2017-09-20  Jakub Jelinek  <jakub@redhat.com>
+
+       * g++.dg/debug/dwarf2/template-params-13.C: New test.
+       * g++.dg/debug/dwarf2/template-params-5.C: Adjust regexps so that
+       it doesn't match newlines.
+       * g++.dg/debug/dwarf2/template-params-3.C: Likewise.
+       * g++.dg/debug/dwarf2/template-func-params-3.C: Likewise.
+       * g++.dg/debug/dwarf2/lang-cpp98.C: Likewise.
+       * g++.dg/debug/dwarf2/template-func-params-2.C: Likewise.
+       * g++.dg/debug/dwarf2/template-func-params-1.C: Likewise.
+       * g++.dg/debug/dwarf2/template-func-params-5.C: Likewise.
+       * g++.dg/debug/dwarf2/template-params-1.C: Likewise.
+       * g++.dg/debug/dwarf2/template-params-2.C: Likewise.
+       * g++.dg/debug/dwarf2/lang-cpp14.C: Likewise.
+       * g++.dg/debug/dwarf2/lang-cpp11.C: Likewise.
+
 2017-09-20  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR c++/64954
index 8079c0e1752c812c6637c7704497007f44cc8cff..6bdc175eb31c9776177875f500ca718e28123faf 100644 (file)
@@ -1,6 +1,6 @@
 // { dg-do compile }
 // { dg-options "-O -std=c++11 -gdwarf-5 -dA" }
 // DW_LANG_C_plus_plus_11 = 0x001a
-// { dg-final { scan-assembler "0x1a.*DW_AT_language" } } */
+// { dg-final { scan-assembler "0x1a\[^\n\r]* DW_AT_language" } } */
 
 int version;
index 448ec7c0a3067f09e49746c7f7b80c98e3f3cba8..4fbc0756715125b498c9ab78fde9fac60d13b68d 100644 (file)
@@ -1,6 +1,6 @@
 // { dg-do compile }
 // { dg-options "-O -std=c++14 -gdwarf-5 -dA" }
 // DW_LANG_C_plus_plus_14 = 0x0021
-// { dg-final { scan-assembler "0x21.*DW_AT_language" } } */
+// { dg-final { scan-assembler "0x21\[^\n\r]* DW_AT_language" } } */
 
 int version;
index e7272dade99d9fe5f6c9e9affd78ffadd37beeab..bdb15d41b20c85fc80f43c394e993c2020690318 100644 (file)
@@ -1,6 +1,6 @@
 // { dg-do compile }
 // { dg-options "-O -std=c++98 -gdwarf-2 -dA" }
 // DW_LANG_C_plus_plus = 0x0004
-// { dg-final { scan-assembler "0x4.*DW_AT_language" } } */
+// { dg-final { scan-assembler "0x4\[^\n\r]* DW_AT_language" } } */
 
 int version;
index 5daa2205f2adb3b638468195f7358803731269e9..3556231edd2d606d120e69ebc139c1246cdb7184 100644 (file)
@@ -3,7 +3,7 @@
 // { dg-options "-gdwarf-2 -dA" }
 // { dg-do compile }
 // { dg-final { scan-assembler "DW_TAG_template_type_param" } }
-// { dg-final { scan-assembler "U.*DW_AT_name" } }
+// { dg-final { scan-assembler "U\[^\n\r]* DW_AT_name" } }
 
 template <class U>
 U
index 670598ba93e512b40919e45c41b2f1043b9f029a..10968288a941f2e97db585cab5922e8a9798f1d9 100644 (file)
@@ -3,8 +3,8 @@
 // { dg-options "-gdwarf-2 -dA" }
 // { dg-do compile }
 // { dg-final { scan-assembler "DW_TAG_template_value_param" } }
-// { dg-final { scan-assembler "i.*DW_AT_name" } }
-// { dg-final { scan-assembler "3.*DW_AT_const_value" } }
+// { dg-final { scan-assembler "i\[^\n\r]* DW_AT_name" } }
+// { dg-final { scan-assembler "3\[^\n\r]* DW_AT_const_value" } }
 
 
 template <int i>
index a356a2ef965c960e2962ba6d18eec4db9574c109..d806104e54a8999f6656dd939d535b99c08d2957 100644 (file)
@@ -2,7 +2,7 @@
 // Origin PR debug/30161
 // { dg-options "-gdwarf-2 -dA -gno-strict-dwarf -fno-merge-debug-strings" }
 // { dg-final { scan-assembler "DW_TAG_template_value_param" } }
-// { dg-final { scan-assembler "f.*DW_AT_name" } }
+// { dg-final { scan-assembler "f\[^\n\r]* DW_AT_name" } }
 // { dg-final { scan-assembler "DW_AT_location\[^\\r\\n\]*\[\\r\\n\]*\[^\\r\\n\]*DW_OP_addr\[^\\r\\n\]*\[\\r\\n\]*\[^\\r\\n\]*_Z4blehv\[^\\r\\n\]*\[\\r\\n\]*\[^\\r\\n\]*DW_OP_stack_value" } } */
 
 typedef void (*func_ptr)();
index cc8b1ac000f83992af4163b271731d86373685f0..cb3a73fa22005cadcdd90a163f9c5e3f6fb01830 100644 (file)
@@ -2,7 +2,7 @@
 // Origin PR debug/30161
 // { dg-options "-gdwarf-2 -dA" }
 // { dg-final { scan-assembler "DW_TAG_template_type_param" } }
-// { dg-final { scan-assembler "T.*DW_AT_name" } }
+// { dg-final { scan-assembler "T\[^\n\r]* DW_AT_name" } }
 
 template <class T>
 struct vector
index b8f92023adf94156495b7a0fcb2463b84f98fa32..21c71ec0624f61ce00b93c145d975c1db8a83595 100644 (file)
@@ -3,7 +3,7 @@
 // { dg-options "-gdwarf-2 -dA" }
 // { dg-do compile }
 // { dg-final { scan-assembler "DW_TAG_template_type_param" } }
-// { dg-final { scan-assembler "U.*DW_AT_name" } }
+// { dg-final { scan-assembler "U\[^\n\r]* DW_AT_name" } }
 
 template <class U>
 class A
diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/template-params-13.C b/gcc/testsuite/g++.dg/debug/dwarf2/template-params-13.C
new file mode 100644 (file)
index 0000000..f32ac17
--- /dev/null
@@ -0,0 +1,10 @@
+// { dg-options "-gdwarf-2 -dA" }
+// { dg-do compile }
+// { dg-final { scan-assembler "DW_TAG_template_value_param" } }
+// { dg-final { scan-assembler "N\[^\n\r]* DW_AT_name" } }
+// { dg-final { scan-assembler "9\[^\n\r]* DW_AT_const_value" } }
+
+template <int N> class C {};
+template <typename T> struct E {};
+E<struct A> f;
+struct A { C<9> g; };
index 0a00fd607e6057fea2ad3514442b850989844c8f..e6ca525ace9fa287fe3b94389a9b0e42c2ec72ef 100644 (file)
@@ -3,8 +3,8 @@
 // { dg-options "-gdwarf-2 -dA" }
 // { dg-do compile }
 // { dg-final { scan-assembler "DW_TAG_template_value_param" } }
-// { dg-final { scan-assembler "i.*DW_AT_name" } }
-// { dg-final { scan-assembler "3.*DW_AT_const_value" } }
+// { dg-final { scan-assembler "i\[^\n\r]* DW_AT_name" } }
+// { dg-final { scan-assembler "3\[^\n\r]* DW_AT_const_value" } }
 
 template <int i>
 struct A
index fc309ecec7fdf296c655013bd129f24ebbac987a..7a9af7701204f789e0fce438c875ae8b3d263263 100644 (file)
@@ -2,7 +2,7 @@
 // Origin PR debug/30161
 // { dg-options "-gdwarf-2 -dA -gno-strict-dwarf -fno-merge-debug-strings" }
 // { dg-final { scan-assembler "DW_TAG_template_value_param" } }
-// { dg-final { scan-assembler "f.*DW_AT_name" } }
+// { dg-final { scan-assembler "f\[^\n\r]* DW_AT_name" } }
 // { dg-final { scan-assembler "DW_AT_location\[^\\r\\n\]*\[\\r\\n\]*\[^\\r\\n\]*DW_OP_addr\[^\\r\\n\]*\[\\r\\n\]*\[^\\r\\n\]*_Z4blehv\[^\\r\\n\]*\[\\r\\n\]*\[^\\r\\n\]*DW_OP_stack_value" } } */
 
 typedef void (*func_ptr) ();
index 02584981db58ca0f37a4549bc54efd28c0790df9..ed08122bebc6e5421e7a161d314c5dbf6ee9f8ce 100644 (file)
@@ -2,7 +2,7 @@
 // Origin PR debug/30161
 // { dg-options "-gdwarf-2 -dA" }
 // { dg-final { scan-assembler "DW_TAG_template_type_param" } }
-// { dg-final { scan-assembler "T.*DW_AT_name" } }
+// { dg-final { scan-assembler "T\[^\n\r]* DW_AT_name" } }
 
 template <class T>
 struct vector