Hi!
Various spots in the FE don't really like if error_mark_node is deeply
embedded in expression operands, in this case tsubst_copy_and_build
creates CONVERT_EXPR on which
is_bitfield_expr_with_lowered_type ICEs.
Fixed by just returning error_mark_node (various other spots in
tsubst_copy_and_build do the same).
While at it, I've discovered 3 spots in the function which were using
return instead of RETURN and thus wouldn't properly restore input_location;
I wonder if eventually this shouldn't be done through some sentinel class
where the destructor would restore input_location and just use return
instead of RETURN.
Anyway, bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
2018-03-02
PR c++/84662
* pt.c (tsubst_copy_and_build) : Use
RETURN instead of return.
: Likewise.
: If op0 is error_mark_node, just return
it instead of wrapping it into CONVERT_EXPR.
* g++.dg/cpp1y/pr84662.C: New test.
--- gcc/cp/pt.c.jj 2018-03-02 00:15:54.097781049 +0100
+++ gcc/cp/pt.c 2018-03-02 12:30:38.127232430 +0100
@@ -17318,14 +17318,14 @@ tsubst_copy_and_build (tree t,
if (targs)
targs = tsubst_template_args (targs, args, complain, in_decl);
if (targs == error_mark_node)
- return error_mark_node;
+ RETURN (error_mark_node);
if (TREE_CODE (templ) == SCOPE_REF)
{
tree name = TREE_OPERAND (templ, 1);
tree tid = lookup_template_function (name, targs);
TREE_OPERAND (templ, 1) = tid;
- return templ;
+ RETURN (templ);
}
if (variable_template_p (templ))
@@ -17401,6 +17401,8 @@ tsubst_copy_and_build (tree t,
{
tree type = tsubst (TREE_TYPE (t), args, complain, in_decl);
tree op0 = RECUR (TREE_OPERAND (t, 0));
+ if (op0 == error_mark_node)
+ RETURN (error_mark_node);
RETURN (build1 (CONVERT_EXPR, type, op0));
}
@@ -17549,7 +17551,7 @@ tsubst_copy_and_build (tree t,
{
tree op0 = RECUR (TREE_OPERAND (t, 0));
tree op1 = RECUR (TREE_OPERAND (t, 1));
- return fold_build_pointer_plus (op0, op1);
+ RETURN (fold_build_pointer_plus (op0, op1));
}
case SCOPE_REF:
--- gcc/testsuite/g++.dg/cpp1y/pr84662.C.jj 2018-03-02 12:32:23.012209212
+0100
+++ gcc/testsuite/g++.dg/cpp1y/pr84662.C2018-03-02 12:32:59.159201202
+0100
@@ -0,0 +1,6 @@
+// PR c++/84662
+// { dg-do compile { target c++14 } }
+// { dg-options "" }
+
+double b;
+a (__attribute__((c (0 && int() - ([] {} && b) || auto;// { dg-error
"expected constructor, destructor, or type conversion before" }
Jakub