]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
* dwarf2out.c (gen_variable_die): Emit DW_AT_const_expr attribute
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 21 Oct 2016 15:11:48 +0000 (15:11 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 21 Oct 2016 15:11:48 +0000 (15:11 +0000)
if needed.  Re-add origin_die variable and its initialization.
cp/
* cp-objcp-common.c (cp_decl_dwarf_attribute): Handle
DW_AT_const_expr.
testsuite/
* g++.dg/debug/dwarf2/constexpr-var-1.C: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@241408 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/cp/ChangeLog
gcc/cp/cp-objcp-common.c
gcc/dwarf2out.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/debug/dwarf2/constexpr-var-1.C [new file with mode: 0644]

index 3c819032613e68a126bd2080bb77fa504ceaabb2..b0bf6e210940d79bc65bff888adb116c242c4f1f 100644 (file)
@@ -1,5 +1,8 @@
 2016-10-21  Jakub Jelinek  <jakub@redhat.com>
 
+       * dwarf2out.c (gen_variable_die): Emit DW_AT_const_expr attribute
+       if needed.  Re-add origin_die variable and its initialization.
+
        * gimplify.c (gimplify_bind_expr): Handle oacc_declare_returns
        even for -fstack-reuse=none, or for volatile vars etc.
 
index d2e6fa818ce6d20367b5f1e5dcc3b99563f4d983..f2c23a230168ee0c37522716aff4691db3a43910 100644 (file)
@@ -1,3 +1,8 @@
+2016-10-21  Jakub Jelinek  <jakub@redhat.com>
+
+       * cp-objcp-common.c (cp_decl_dwarf_attribute): Handle
+       DW_AT_const_expr.
+
 2016-10-17  Jakub Jelinek  <jakub@redhat.com>
 
        * cp-objcp-common.h (cp_function_decl_explicit_p,
index abcc1ca3d5dca396a793b873336d8ad2618dea85..50ac07f07905858649edf8b39f92af8f08042416 100644 (file)
@@ -168,6 +168,11 @@ cp_decl_dwarf_attribute (const_tree decl, int attr)
        }
       break;
 
+    case DW_AT_const_expr:
+      if (VAR_OR_FUNCTION_DECL_P (decl) && DECL_DECLARED_CONSTEXPR_P (decl))
+       return 1;
+      break;
+
     default:
       break;
     }
index 1d2e385bdde88c647ada181bc09b6e064a817b23..3e3dea999d1a15b425d56651cc033b3b89f09ad2 100644 (file)
@@ -21264,6 +21264,7 @@ gen_variable_die (tree decl, tree origin, dw_die_ref context_die)
   tree ultimate_origin;
   dw_die_ref var_die;
   dw_die_ref old_die = decl ? lookup_decl_die (decl) : NULL;
+  dw_die_ref origin_die = NULL;
   bool declaration = (DECL_EXTERNAL (decl_or_origin)
                      || class_or_namespace_scope_p (context_die));
   bool specialization_p = false;
@@ -21423,7 +21424,7 @@ gen_variable_die (tree decl, tree origin, dw_die_ref context_die)
     var_die = new_die (DW_TAG_variable, context_die, decl);
 
   if (origin != NULL)
-    add_abstract_origin_attribute (var_die, origin);
+    origin_die = add_abstract_origin_attribute (var_die, origin);
 
   /* Loop unrolling can create multiple blocks that refer to the same
      static variable, so we must test for the DW_AT_declaration flag.
@@ -21509,6 +21510,14 @@ gen_variable_die (tree decl, tree origin, dw_die_ref context_die)
     }
   else
     tree_add_const_value_attribute_for_decl (var_die, decl_or_origin);
+
+  if ((dwarf_version >= 4 || !dwarf_strict)
+      && lang_hooks.decls.decl_dwarf_attribute (decl_or_origin,
+                                               DW_AT_const_expr) == 1
+      && !get_AT (var_die, DW_AT_const_expr)
+      && (origin_die == NULL || get_AT (origin_die, DW_AT_const_expr) == NULL)
+      && !specialization_p)
+    add_AT_flag (var_die, DW_AT_const_expr, 1);
 }
 
 /* Generate a DIE to represent a named constant.  */
index 83414ed3833e6e5782183cdfbec2eac86900d9c2..fafdbfcf93bb0d6aa01c64d2cf19ec09adcc2d99 100644 (file)
@@ -1,3 +1,7 @@
+2016-10-21  Jakub Jelinek  <jakub@redhat.com>
+
+       * g++.dg/debug/dwarf2/constexpr-var-1.C: New test.
+
 2016-10-21  Paul Thomas  <pault@gcc.gnu.org>
 
        PR fortran/69566
diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/constexpr-var-1.C b/gcc/testsuite/g++.dg/debug/dwarf2/constexpr-var-1.C
new file mode 100644 (file)
index 0000000..045d5fe
--- /dev/null
@@ -0,0 +1,9 @@
+// { dg-do compile }
+// { dg-options "-O -std=c++11 -g -dA -gno-strict-dwarf" }
+// { dg-final { scan-assembler-times " DW_AT_const_expr" 2 } }
+
+constexpr int a = 5;
+struct S
+{
+  static constexpr int b = 6;
+} s;