mirror of
https://github.com/gcc-mirror/gcc.git
synced 2026-05-06 14:59:39 +02:00
c++/reflection: ICE with lifetime extension of consteval-only [PR124575]
Here we ICE in output_constant because we attempt to emit the temporary created for lifetime extension of a consteval-only expression. Like other consteval-only variables, the temporary also has to be marked DECL_EXTERNAL so that we don't emit it. I tried to do the setting in make_temporary_var_for_ref_to_temp, but then we ICE in set_decl_context_in_fn. PR c++/124575 gcc/cp/ChangeLog: * call.cc (set_up_extended_ref_temp): If var is consteval-only, mark it DECL_EXTERNAL. gcc/testsuite/ChangeLog: * g++.dg/reflect/expr16.C: New test. Reviewed-by: Jason Merrill <jason@redhat.com>
This commit is contained in:
@@ -14351,6 +14351,10 @@ set_up_extended_ref_temp (tree decl, tree expr, vec<tree, va_gc> **cleanups,
|
||||
/* Any reference temp has a non-trivial initializer. */
|
||||
DECL_NONTRIVIALLY_INITIALIZED_P (var) = true;
|
||||
|
||||
/* Don't output reflection variables. */
|
||||
if (consteval_only_p (var))
|
||||
DECL_EXTERNAL (var) = true;
|
||||
|
||||
/* If the initializer is constant, put it in DECL_INITIAL so we get
|
||||
static initialization and use in constant expressions. */
|
||||
init = maybe_constant_init (expr, var, /*manifestly_const_eval=*/true);
|
||||
|
||||
5
gcc/testsuite/g++.dg/reflect/expr16.C
Normal file
5
gcc/testsuite/g++.dg/reflect/expr16.C
Normal file
@@ -0,0 +1,5 @@
|
||||
// PR c++/124575
|
||||
// { dg-do compile { target c++26 } }
|
||||
// { dg-additional-options "-freflection" }
|
||||
|
||||
constexpr const decltype(^^::) &r = ^^int;
|
||||
Reference in New Issue
Block a user