On 10/26/25 7:31 AM, Nathaniel Shead wrote:
I haven't found any particular testcases affected by this but I couldn't
guarantee it wouldn't cause issues either, so seems worth doing IMO.
OK for trunk?
-- >8 --
gcc/cp/ChangeLog:
* constraint.cc (diagnose_trait_expr): Check for
error_mark_node, reset input_location.
Signed-off-by: Nathaniel Shead <[email protected]>
---
gcc/cp/constraint.cc | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/gcc/cp/constraint.cc b/gcc/cp/constraint.cc
index 309ebc81324..60095d3c4f7 100644
--- a/gcc/cp/constraint.cc
+++ b/gcc/cp/constraint.cc
@@ -3075,6 +3075,10 @@ diagnose_trait_expr (location_t loc, tree expr, tree
args)
tree t1 = TRAIT_EXPR_TYPE1 (expr);
tree t2 = TRAIT_EXPR_TYPE2 (expr);
+ if (t1 == error_mark_node || t2 == error_mark_node)
+ return;
This should never happen, we should have checked for error_mark_node
sooner and not built the TRAIT_EXPR in the first place if one of the
types was erroneous. If you want to check here it should be an assert
rather than a return.
+
+ iloc_sentinel ils (loc);
Adding the iloc_sentinel is OK.
/* For traits intrinsically about the properties of user-defined types,
decl_loc will point to the declaration of that type. */