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