* [C++ PATCH] Fix C++ ICE due to CONVERT_EXPR of error_mark_node (PR c++/84662)
@ 2018-03-02 16:25 Jakub Jelinek
2018-03-02 16:46 ` Nathan Sidwell
0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2018-03-02 16:25 UTC (permalink / raw)
To: Jason Merrill, Nathan Sidwell; +Cc: gcc-patches
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 <some_type, error_mark_node> 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 <jakub@redhat.com>
PR c++/84662
* pt.c (tsubst_copy_and_build) <case TEMPLATE_ID_EXPR>: Use
RETURN instead of return.
<case POINTER_PLUS_EXPR>: Likewise.
<case CONVERT_EXPR>: 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.C 2018-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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [C++ PATCH] Fix C++ ICE due to CONVERT_EXPR of error_mark_node (PR c++/84662)
2018-03-02 16:25 [C++ PATCH] Fix C++ ICE due to CONVERT_EXPR of error_mark_node (PR c++/84662) Jakub Jelinek
@ 2018-03-02 16:46 ` Nathan Sidwell
0 siblings, 0 replies; 2+ messages in thread
From: Nathan Sidwell @ 2018-03-02 16:46 UTC (permalink / raw)
To: Jakub Jelinek, Jason Merrill; +Cc: gcc-patches
On 03/02/2018 11:25 AM, Jakub Jelinek wrote:
> 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 <some_type, error_mark_node> 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?
ok, thanks
nathan
--
Nathan Sidwell
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-03-02 16:46 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-02 16:25 [C++ PATCH] Fix C++ ICE due to CONVERT_EXPR of error_mark_node (PR c++/84662) Jakub Jelinek
2018-03-02 16:46 ` Nathan Sidwell
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).