This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix C++/28988, g++ does not check first type name in pseudo-destructor-name
- From: Andrew Pinski <pinskia at gmail dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Sat, 28 Oct 2006 17:06:00 -0700
- Subject: [PATCH] Fix C++/28988, g++ does not check first type name in pseudo-destructor-name
The problem here is that we now with the new C++ parser go through a
different mechanism for destructors which does not error out for some
invalid code cases. This fixes the problem by adding the check to the
new mechanism.
OK? Bootstrapped and tested on i686-linux-gnu with no regressions.
Thanks,
Andrew Pinski
cp/ChangeLog:
* semantics.c (finish_pseudo_destructor_expr): Check the
destrutor name by calling check_dtor_name.
testsuite/ChangeLog:
* g++.dg/expr/dtor4.C: New test.
Index: testsuite/g++.dg/expr/dtor4.C
===================================================================
--- testsuite/g++.dg/expr/dtor4.C (revision 0)
+++ testsuite/g++.dg/expr/dtor4.C (revision 0)
@@ -0,0 +1,10 @@
+typedef int C;
+typedef double D;
+
+void
+f ()
+{
+ C o;
+
+ o.D::~C (); // { dg-error "" }
+}
Index: cp/semantics.c
===================================================================
--- cp/semantics.c (revision 118112)
+++ cp/semantics.c (working copy)
@@ -1931,6 +1931,13 @@ finish_pseudo_destructor_expr (tree obje
error ("invalid qualifying scope in pseudo-destructor name");
return error_mark_node;
}
+ if (scope && TYPE_P (scope) && !check_dtor_name (scope, destructor))
+ {
+ error ("qualified type %qT does not match destructor name ~%qT",
+ scope, destructor);
+ return error_mark_node;
+ }
+
/* [expr.pseudo] says both: