summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIain Sandoe <iain@sandoe.co.uk>2023-03-30 13:14:23 +0530
committerIain Sandoe <iain@sandoe.co.uk>2023-05-16 20:06:57 +0100
commit72f004746d87f01e5e3872af3214e3fa1b48dfa8 (patch)
treefc5672b1f714e1f7e0ca3a4d73d8a1b190bc23d5
parent66a111413201526e6f75c1e8ddc55f4eaf1c4145 (diff)
downloadgcc-72f004746d87f01e5e3872af3214e3fa1b48dfa8.tar.gz
c++,coroutines: Stabilize names of promoted slot vars [PR101118].
When we need to 'promote' a value (i.e. store it in the coroutine frame) it is given a frame entry name. This was based on the DECL_UID for slot vars. However, when LTO is used, the names from multiple TUs become visible at the same time, and the DECL_UIDs usually differ between units. This leads to a "ODR mismatch" warning for the frame type. The fix here is to use the current promoted temporaries count to produce the name, this is stable between TUs and computed per coroutine. Signed-off-by: Iain Sandoe <iain@sandoe.co.uk> PR c++/101118 gcc/cp/ChangeLog: * coroutines.cc (flatten_await_stmt): Use the current count of promoted temporaries to build a unique name for the frame entries. (cherry picked from commit fc4cde2e6aa4d6ebdf7f70b7b4359fb59a1915ae)
-rw-r--r--gcc/cp/coroutines.cc2
1 files changed, 1 insertions, 1 deletions
diff --git a/gcc/cp/coroutines.cc b/gcc/cp/coroutines.cc
index b20e773bff6..4cb0db315aa 100644
--- a/gcc/cp/coroutines.cc
+++ b/gcc/cp/coroutines.cc
@@ -2874,7 +2874,7 @@ flatten_await_stmt (var_nest_node *n, hash_set<tree> *promoted,
tree init = t;
temps_used->add (init);
tree var_type = TREE_TYPE (init);
- char *buf = xasprintf ("D.%d", DECL_UID (TREE_OPERAND (init, 0)));
+ char *buf = xasprintf ("T%03u", (unsigned) temps_used->elements ());
tree var = build_lang_decl (VAR_DECL, get_identifier (buf), var_type);
DECL_ARTIFICIAL (var) = true;
free (buf);