DECL_HAS_VALUE_EXPR_P (v[i]) = 1;
}
}
+ else if (DECL_NAMESPACE_SCOPE_P (decl) && !seen_error ())
+ {
+ tree attr = NULL_TREE, *pa = &attr;
+ for (unsigned int i = 0; i < count; i++)
+ if ((unsigned) pack != i
+ && DECL_HAS_VALUE_EXPR_P (v[i])
+ && !DECL_IGNORED_P (v[i]))
+ {
+ (*debug_hooks->early_global_decl) (v[i]);
+ *pa = build_tree_list (NULL_TREE, v[i]);
+ pa = &TREE_CHAIN (*pa);
+ }
+ if (attr)
+ DECL_ATTRIBUTES (decl)
+ = tree_cons (get_identifier ("structured bindings"),
+ attr, DECL_ATTRIBUTES (decl));
+ }
return false;
}
{
dw_die_ref die = lookup_decl_die (var->decl);
if (die)
- die->die_perennial_p = 1;
+ {
+ die->die_perennial_p = 1;
+ if (tree attr = lookup_attribute ("structured bindings",
+ DECL_ATTRIBUTES (var->decl)))
+ for (tree d = TREE_VALUE (attr); d; d = TREE_CHAIN (d))
+ {
+ die = lookup_decl_die (TREE_VALUE (d));
+ if (die)
+ die->die_perennial_p = 1;
+ }
+ }
}
}
&& is_trivial_indirect_ref (DECL_VALUE_EXPR (decl))))
tree_add_const_value_attribute_for_decl (die, decl);
else
- add_location_or_const_value_attribute (die, decl, false);
+ {
+ add_location_or_const_value_attribute (die, decl, false);
+ /* For C++ structured bindings at namespace scope when processing
+ the underlying variable also add locations on the structured
+ bindings which refer to it (unless they are tuple-based, then
+ they are separate VAR_DECLs registered in varpool). */
+ if (tree attr = lookup_attribute ("structured bindings",
+ DECL_ATTRIBUTES (decl)))
+ for (tree d = TREE_VALUE (attr); d; d = TREE_CHAIN (d))
+ {
+ die = lookup_decl_die (TREE_VALUE (d));
+ if (die)
+ add_location_or_const_value_attribute (die,
+ TREE_VALUE (d),
+ false);
+ }
+ }
}
}
}
--- /dev/null
+// PR debug/122968
+// { dg-do run { target int32plus } }
+// { dg-options "-g" }
+
+struct S { unsigned a; unsigned long long b; short c; } s = { 10, 53967718, -42 };
+auto [ a, b, c ] = s;
+static auto [ d, e, f ] = S { 5, 1245234412, -231 };
+auto *p = &d;
+volatile int v;
+namespace N {
+ auto [ a, b, c ] = S { 8, 7135498, 256 };
+ int arr[4] = { 1, 2, 3, 4 };
+ auto [ d, e, f, g ] = arr;
+}
+
+int
+main ()
+{
+ asm volatile ("" : : "g" (&a), "g" (&b), "g" (&c) : "memory");
+ asm volatile ("" : : "g" (&d), "g" (&e), "g" (&f) : "memory");
+ asm volatile ("" : : "g" (&N::a), "g" (&N::b), "g" (&N::c) : "memory");
+ asm volatile ("" : : "g" (&N::d), "g" (&N::e), "g" (&N::f) : "memory");
+ asm volatile ("" : : "g" (&N::g) : "memory");
+ v = 1;
+// { dg-final { gdb-test 24 "a" "10" } }
+// { dg-final { gdb-test 24 "b" "53967718" } }
+// { dg-final { gdb-test 24 "c" "-42" } }
+// { dg-final { gdb-test 24 "d" "5" } }
+// { dg-final { gdb-test 24 "e" "1245234412" } }
+// { dg-final { gdb-test 24 "f" "-231" } }
+// { dg-final { gdb-test 24 "N::a" "8" } }
+// { dg-final { gdb-test 24 "N::b" "7135498" } }
+// { dg-final { gdb-test 24 "N::c" "256" } }
+// { dg-final { gdb-test 24 "N::d" "1" } }
+// { dg-final { gdb-test 24 "N::e" "2" } }
+// { dg-final { gdb-test 24 "N::f" "3" } }
+// { dg-final { gdb-test 24 "N::g" "4" } }
+}