From: Jakub Jelinek Date: Wed, 20 Sep 2017 09:04:22 +0000 (+0200) Subject: dwarf2out.c (tree_add_const_value_attribute): For INTEGER_CST that fits into uhwi... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=88272c019414e6558db9c6c72053415fa88e0b5e;p=gcc.git dwarf2out.c (tree_add_const_value_attribute): For INTEGER_CST that fits into uhwi or shwi... * 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 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f620568e85e..b82df9f61ad 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,10 @@ 2017-09-20 Jakub Jelinek + * 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. diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index d757d2d4553..eed3a40c422 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -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); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d0cea296d6a..0247ada60f4 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,19 @@ +2017-09-20 Jakub Jelinek + + * 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 PR c++/64954 diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/lang-cpp11.C b/gcc/testsuite/g++.dg/debug/dwarf2/lang-cpp11.C index 8079c0e1752..6bdc175eb31 100644 --- a/gcc/testsuite/g++.dg/debug/dwarf2/lang-cpp11.C +++ b/gcc/testsuite/g++.dg/debug/dwarf2/lang-cpp11.C @@ -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; diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/lang-cpp14.C b/gcc/testsuite/g++.dg/debug/dwarf2/lang-cpp14.C index 448ec7c0a30..4fbc0756715 100644 --- a/gcc/testsuite/g++.dg/debug/dwarf2/lang-cpp14.C +++ b/gcc/testsuite/g++.dg/debug/dwarf2/lang-cpp14.C @@ -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; diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/lang-cpp98.C b/gcc/testsuite/g++.dg/debug/dwarf2/lang-cpp98.C index e7272dade99..bdb15d41b20 100644 --- a/gcc/testsuite/g++.dg/debug/dwarf2/lang-cpp98.C +++ b/gcc/testsuite/g++.dg/debug/dwarf2/lang-cpp98.C @@ -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; diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/template-func-params-1.C b/gcc/testsuite/g++.dg/debug/dwarf2/template-func-params-1.C index 5daa2205f2a..3556231edd2 100644 --- a/gcc/testsuite/g++.dg/debug/dwarf2/template-func-params-1.C +++ b/gcc/testsuite/g++.dg/debug/dwarf2/template-func-params-1.C @@ -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 U diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/template-func-params-2.C b/gcc/testsuite/g++.dg/debug/dwarf2/template-func-params-2.C index 670598ba93e..10968288a94 100644 --- a/gcc/testsuite/g++.dg/debug/dwarf2/template-func-params-2.C +++ b/gcc/testsuite/g++.dg/debug/dwarf2/template-func-params-2.C @@ -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 diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/template-func-params-3.C b/gcc/testsuite/g++.dg/debug/dwarf2/template-func-params-3.C index a356a2ef965..d806104e54a 100644 --- a/gcc/testsuite/g++.dg/debug/dwarf2/template-func-params-3.C +++ b/gcc/testsuite/g++.dg/debug/dwarf2/template-func-params-3.C @@ -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)(); diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/template-func-params-5.C b/gcc/testsuite/g++.dg/debug/dwarf2/template-func-params-5.C index cc8b1ac000f..cb3a73fa220 100644 --- a/gcc/testsuite/g++.dg/debug/dwarf2/template-func-params-5.C +++ b/gcc/testsuite/g++.dg/debug/dwarf2/template-func-params-5.C @@ -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 struct vector diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/template-params-1.C b/gcc/testsuite/g++.dg/debug/dwarf2/template-params-1.C index b8f92023adf..21c71ec0624 100644 --- a/gcc/testsuite/g++.dg/debug/dwarf2/template-params-1.C +++ b/gcc/testsuite/g++.dg/debug/dwarf2/template-params-1.C @@ -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 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 index 00000000000..f32ac1711ec --- /dev/null +++ b/gcc/testsuite/g++.dg/debug/dwarf2/template-params-13.C @@ -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 class C {}; +template struct E {}; +E f; +struct A { C<9> g; }; diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/template-params-2.C b/gcc/testsuite/g++.dg/debug/dwarf2/template-params-2.C index 0a00fd607e6..e6ca525ace9 100644 --- a/gcc/testsuite/g++.dg/debug/dwarf2/template-params-2.C +++ b/gcc/testsuite/g++.dg/debug/dwarf2/template-params-2.C @@ -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 struct A diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/template-params-3.C b/gcc/testsuite/g++.dg/debug/dwarf2/template-params-3.C index fc309ecec7f..7a9af770120 100644 --- a/gcc/testsuite/g++.dg/debug/dwarf2/template-params-3.C +++ b/gcc/testsuite/g++.dg/debug/dwarf2/template-params-3.C @@ -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) (); diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/template-params-5.C b/gcc/testsuite/g++.dg/debug/dwarf2/template-params-5.C index 02584981db5..ed08122bebc 100644 --- a/gcc/testsuite/g++.dg/debug/dwarf2/template-params-5.C +++ b/gcc/testsuite/g++.dg/debug/dwarf2/template-params-5.C @@ -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 struct vector