]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: Ensure DECL_CONTEXT is set for temporary vars [PR114005]
authorNathaniel Shead <nathanieloshead@gmail.com>
Thu, 29 Feb 2024 11:49:13 +0000 (22:49 +1100)
committerNathaniel Shead <nathanieloshead@gmail.com>
Fri, 1 Mar 2024 22:04:15 +0000 (09:04 +1100)
commit2823b4d96d9ec4ad4e67e5e8edaa1b060a467491
tree6aa3d5d183995e298f09bfae54c20ce35daacb9a
parentb7b387e1200fd182599195979d5d21656fa8969d
c++: Ensure DECL_CONTEXT is set for temporary vars [PR114005]

Modules streaming requires DECL_CONTEXT to be set for anything streamed.
This patch ensures that 'create_temporary_var' does set a DECL_CONTEXT
for these variables (such as the backing storage for initializer_lists)
even if not inside a function declaration.

PR c++/114005

gcc/cp/ChangeLog:

* init.cc (create_temporary_var): Use current_scope instead of
current_function_decl.

gcc/testsuite/ChangeLog:

* g++.dg/modules/pr114005_a.C: New test.
* g++.dg/modules/pr114005_b.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
gcc/cp/init.cc
gcc/testsuite/g++.dg/modules/pr114005_a.C [new file with mode: 0644]
gcc/testsuite/g++.dg/modules/pr114005_b.C [new file with mode: 0644]