aboutsummaryrefslogtreecommitdiff
path: root/gcc/dwarf2out.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2016-10-21 17:11:48 +0200
committerJakub Jelinek <jakub@gcc.gnu.org>2016-10-21 17:11:48 +0200
commit8e6982f7aac4c8d539f194e302fb67179f98c3f1 (patch)
tree23d9b415e858a7e4be5217e8b836ea49a685e47b /gcc/dwarf2out.c
parentf9faea3725f6064ab226f1089d255b4f23bc5bef (diff)
downloadgcc-8e6982f7aac4c8d539f194e302fb67179f98c3f1.zip
gcc-8e6982f7aac4c8d539f194e302fb67179f98c3f1.tar.gz
gcc-8e6982f7aac4c8d539f194e302fb67179f98c3f1.tar.bz2
dwarf2out.c (gen_variable_die): Emit DW_AT_const_expr attribute if needed.
* dwarf2out.c (gen_variable_die): Emit DW_AT_const_expr attribute 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. From-SVN: r241408
Diffstat (limited to 'gcc/dwarf2out.c')
-rw-r--r--gcc/dwarf2out.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 1d2e385..3e3dea9 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -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. */