This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] Fix PR c++/9278


The C++ frontend fails to diagnose invalid code like the following:

  typedef void VOID;
  int foo(VOID);

The patch below fixes this by not allowing typedef-names for 'void'
in parameter lists.

Bootstrapped and regtested on i686-pc-linux-gnu.
Ok for mainline?
What about the 4.1 branch?

Regards,
Volker



2005-11-23  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>

	PR c++/9278
	* decl.c (grokparms): Do not allow typedef-names in a '(void)'
	parmlist.

============================================================================
--- gcc/gcc/cp/decl.c	2005-09-09 02:51:56 +0200
+++ gcc/gcc/cp/decl.c	2005-11-23 22:53:55 +0100
@@ -8598,6 +8598,7 @@ grokparms (cp_parameter_declarator *firs
       if (VOID_TYPE_P (type))
 	{
 	  if (same_type_p (type, void_type_node)
+	      && DECL_SELF_REFERENCE_P (type)
 	      && !DECL_NAME (decl) && !result && !parm->next && !ellipsis)
 	    /* this is a parmlist of `(void)', which is ok.  */
 	    break;
============================================================================

2005-11-23  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>

	PR c++/9278
	* g++.dg/other/void1.C: New test.

============================================================================
--- gcc/gcc/testsuite/g++.dg/other/void1.C   2003-09-23 19:59:22 +0200
+++ gcc/gcc/testsuite/g++.dg/other/void1.C   2005-11-23 23:08:20 +0100
@@ -0,0 +1,16 @@
+// PR c++/9278
+// { dg-do compile }
+
+typedef void VOID;
+
+int foo(void);
+int bar(VOID);                // { dg-error "type|invalid use" }
+
+template<int> int foo(void);
+template<int> int bar(VOID);  // { dg-error "type|invalid use" }
+
+struct A
+{
+  int foo(void);
+  int bar(VOID);              // { dg-error "type|invalid use" }
+};
============================================================================



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]