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;
+
+  iloc_sentinel ils (loc);
 
   /* For traits intrinsically about the properties of user-defined types,
      decl_loc will point to the declaration of that type.  */
-- 
2.51.0

Reply via email to