Check is_capture_proxy sooner

...and don't check !normal.
This commit is contained in:
Marek Polacek
2026-01-07 17:50:13 -05:00
parent b6bd6249bd
commit cd9243f298
2 changed files with 9 additions and 9 deletions

View File

@@ -134,6 +134,14 @@ get_reflection (location_t loc, tree t, reflect_kind kind/*=REFLECT_UNDEF*/)
"parameter %qD", t);
return error_mark_node;
}
/* If the id-expression denotes a variable declared by an init-capture,
R is ill-formed. */
else if (is_capture_proxy (t))
{
error_at (loc, "%<^^%> cannot be applied to a local entity declared "
"by init-capture");
return error_mark_node;
}
/* If the id-expression denotes a local parameter introduced by
a requires-expression, R is ill-formed. */
else if (TREE_CODE (t) == PARM_DECL && CONSTRAINT_VAR_P (t))
@@ -159,14 +167,6 @@ get_reflection (location_t loc, tree t, reflect_kind kind/*=REFLECT_UNDEF*/)
inform (DECL_SOURCE_LOCATION (t), "%qD declared here", t);
return error_mark_node;
}
/* If the id-expression denotes a variable declared by an init-capture,
R is ill-formed. */
else if (is_capture_proxy (t) && !is_normal_capture_proxy (t))
{
error_at (loc, "%<^^%> cannot be applied to a local entity declared "
"by init-capture");
return error_mark_node;
}
/* If lookup finds a declaration that replaced a using-declarator during
a single search, R is ill-formed. */
else if (TREE_CODE (t) == USING_DECL

View File

@@ -43,7 +43,7 @@ h ()
constexpr auto r3 = ^^y; // { dg-error "intervening lambda expression" }
[x_]() {
constexpr auto r4 = ^^x_; // { dg-error "intervening lambda expression" }
constexpr auto r4 = ^^x_; // { dg-error "local entity declared by init-capture" }
};
};
}