[C++ PATCH] Fix pseudo-dtor related ice-on-invalid (PR c++/34068)
Jakub Jelinek
jakub@redhat.com
Sun Nov 11 23:21:00 GMT 2007
Hi!
Before my recent patch we wouldn't try to parse this as a pseudo dtor,
but rejected it right away. Now that we try to parse it as pseudo-dtor,
the object in cp_parser_postfix_dot_deref_expression is type dependent
and not error_mark_node, so that routine IMHO does the right thing, because
it provably can't be anything but pseudo-dtor (as the type in ~X () is
scalar), but whether it is a pseudo-dtor or invalid code needs checking only
at instantiation time (at least with -fpermissive, but even without it
the tree doesn't hint anything went wrong).
At tsubst_copy_and_build time the first argument of PSEUDO_DTOR_EXPR
after RECUR is error_mark_node and an error has been already reported.
Either we can check for this in finish_pseudo_destructor_expr as done
by the patch below, or in the caller (tsubst_copy_and_build <case
PSEUDO_DTOR_EXPR>).
Regtested on x86_64-linux, ok for trunk?
2007-11-11 Jakub Jelinek <jakub@redhat.com>
PR c++/34068
* semantics.c (finish_pseudo_destructor_expr): Handle
object == error_mark_node.
* g++.dg/template/pseudodtor4.C: New test.
--- gcc/cp/semantics.c.jj 2007-11-08 01:19:18.000000000 +0100
+++ gcc/cp/semantics.c 2007-11-11 23:00:06.000000000 +0100
@@ -1998,7 +1998,7 @@ finish_this_expr (void)
tree
finish_pseudo_destructor_expr (tree object, tree scope, tree destructor)
{
- if (destructor == error_mark_node)
+ if (object == error_mark_node || destructor == error_mark_node)
return error_mark_node;
gcc_assert (TYPE_P (destructor));
--- gcc/testsuite/g++.dg/template/pseudodtor4.C.jj 2007-11-11 23:01:32.000000000 +0100
+++ gcc/testsuite/g++.dg/template/pseudodtor4.C 2007-11-11 23:03:45.000000000 +0100
@@ -0,0 +1,10 @@
+// PR c++/34068
+// { dg-do compile }
+
+template <typename> struct A
+{
+ typedef int X;
+ A () { T (). ~X (); } // { dg-error "there are no arguments to|fpermissive|was not declared in this scope" }
+};
+
+A <int> a;
Jakub
More information about the Gcc-patches
mailing list