*non_constant_p = true;
return call;
}
+ if (TYPE_BEING_DEFINED (type))
+ {
+ if (!cxx_constexpr_quiet_p (ctx))
+ error_at (loc, "first %<define_aggregate%> argument is a reflection "
+ "of a class type %qT being defined", type);
+ *non_constant_p = true;
+ return call;
+ }
hash_set<tree> nameset;
for (int i = 0; i < TREE_VEC_LENGTH (rvec); ++i)
{
tree cscope = NULL_TREE, tscope = NULL_TREE;
for (tree c = TYPE_CONTEXT (CP_DECL_CONTEXT (consteval_block)); c;
c = get_containing_scope (c))
- {
- if (c == type)
- {
- auto_diagnostic_group d;
- error_at (loc, "%<define_aggregate%> evaluated from "
- "%<consteval%> block enclosed by %qT being "
- "defined", type);
- inform (DECL_SOURCE_LOCATION (consteval_block),
- "%<consteval%> block defined here");
- return get_reflection_raw (loc, orig_type);
- }
- if (cscope == NULL_TREE
- && (TYPE_P (c) || TREE_CODE (c) == FUNCTION_DECL))
+ if (TYPE_P (c) || TREE_CODE (c) == FUNCTION_DECL)
+ {
cscope = c;
- }
+ break;
+ }
for (tree c = TYPE_CONTEXT (type); c; c = get_containing_scope (c))
{
if (c == consteval_block)
const bool a = foo (); // { dg-error "call to consteval function 'foo\\\(\\\)' is not a constant expression" }
struct S3 {
- consteval { // { dg-message "'consteval' block defined here" }
- define_aggregate (^^S3, {}); // { dg-error "'define_aggregate' evaluated from 'consteval' block enclosed by 'S3' being defined" }
+ consteval {
+ define_aggregate (^^S3, {}); // { dg-error "first 'define_aggregate' argument is a reflection of a class type .S3. being defined" }
}
};
template <typename T>
struct S5 {
- consteval { // { dg-message "'consteval' block defined here" }
- define_aggregate (^^S5 <T>, {}); // { dg-error "'define_aggregate' evaluated from 'consteval' block enclosed by 'S5<int>' being defined" }
+ consteval {
+ define_aggregate (^^S5 <T>, {}); // { dg-error "first 'define_aggregate' argument is a reflection of a class type .S5<int>. being defined" }
}
};
S5 <int> s5;
-consteval bool bar (info x) { return define_aggregate (x, {}) == x; } // { dg-error "'define_aggregate' evaluated from 'consteval' block enclosed by 'S6' being defined" }
+consteval bool bar (info x) { return define_aggregate (x, {}) == x; } // { dg-error "first 'define_aggregate' argument is a reflection of a class type .S6. being defined" }
struct S6 {
- consteval { // { dg-message "'consteval' block defined here" }
+ consteval {
bar (^^S6);
}
};
-consteval bool baz (info x) { return define_aggregate (x, {}) == x; } // { dg-error "'define_aggregate' evaluated from 'consteval' block enclosed by 'S7<char>' being defined" }
+consteval bool baz (info x) { return define_aggregate (x, {}) == x; } // { dg-error "first 'define_aggregate' argument is a reflection of a class type .S7<char>. being defined" }
template <typename T>
struct S7 {
- consteval { // { dg-message "'consteval' block defined here" }
+ consteval {
baz (^^S7 <T>);
}
};
using namespace std::meta;
struct S0 {
- consteval { // { dg-message "'consteval' block defined here" }
+ consteval {
std::meta::define_aggregate(^^S0, {}); // error: scope associated with S0 encloses the consteval block
- } // { dg-error "'define_aggregate' evaluated from 'consteval' block enclosed by 'S0' being defined" "" { target *-*-* } .-1 }
+ } // { dg-error "first 'define_aggregate' argument is a reflection of a class type .S0. being defined" "" { target *-*-* } .-1 }
};
struct S1;