This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch] Fix PR 19894: Reject pointer-to-member of type void
- From: Volker Reichelt <reichelt at igpm dot rwth-aachen dot de>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 08 Jun 2005 01:10:06 +0200 (CEST)
- Subject: [patch] Fix PR 19894: Reject pointer-to-member of type void
In the following testcase
template<typename T> struct A
{
T A::* p;
};
A<void> a;
we do not diagnose the fact that A<void>::p is a pointer to a member
of type void, which is invalid.
This is an omission in tsubst where we test e.g. for (invalid) reference
types, but fail to check for a void type.
The following patch adds the missing test.
Bootstrapped and regtested on i686-pc-linux-gnu.
Ok for mainline (it's not a regression)?
Regards,
Volker
2005-06-07 Volker Reichelt <reichelt@igpm.rwth-aachen.de>
PR c++/19894
* pt.c (tsubst): Reject pointer-to-member of type void.
===================================================================
--- gcc/gcc/cp/pt.c 3 Jun 2005 16:18:30 -0000 1.978.2.12
+++ gcc/gcc/cp/pt.c 7 Jun 2005 18:12:13 -0000
@@ -7233,7 +7233,12 @@ tsubst (tree t, tree args, tsubst_flags_
{
if (complain & tf_error)
error ("creating pointer to member reference type %qT", type);
-
+ return error_mark_node;
+ }
+ if (TREE_CODE (type) == VOID_TYPE)
+ {
+ if (complain & tf_error)
+ error ("creating pointer to member of type void");
return error_mark_node;
}
gcc_assert (TREE_CODE (type) != METHOD_TYPE);
===================================================================
2005-06-07 Volker Reichelt <reichelt@igpm.rwth-aachen.de>
PR c++/19894
* g++.dg/template/ptrmem15.C: New test.
===================================================================
--- gcc/gcc/testsuite/g++.dg/template/ptrmem15.C 2005-05-27 23:07:43.900843888 +0200
+++ gcc/gcc/testsuite/g++.dg/template/ptrmem15.C 2005-06-07 20:23:54.000000000 +0200
@@ -0,0 +1,9 @@
+// PR c++/19894
+// Origin: Volker Reichelt <reichelt@igpm.rwth-aachen.de>
+
+template<typename T> struct A
+{
+ T A::* p; // { dg-error "void" }
+};
+
+A<void> a; // { dg-error "instantiated" }
===================================================================