This is the mail archive of the 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]

C++ PATCH for c++/37037 (declaring template class member function with a typedef)

The code in grokdeclarator for declaring a function with a typedef was creating a void PARM_DECL.

Tested x86_64-pc-linux-gnu, applied to trunk.
commit 5853452a17a254cc8f8e698e0bcdd1049822d6de
Author: Jason Merrill <>
Date:   Thu Nov 12 17:16:41 2009 -0500

    	PR c++/37037
    	* decl.c (grokdeclarator): Don't generate a void PARM_DECL.

diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 5e2f85f..e23634f 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -8993,7 +8993,9 @@ grokdeclarator (const cp_declarator *declarator,
       tree decls = NULL_TREE;
       tree args;
-      for (args = TYPE_ARG_TYPES (type); args; args = TREE_CHAIN (args))
+      for (args = TYPE_ARG_TYPES (type);
+	   args && args != void_list_node;
+	   args = TREE_CHAIN (args))
 	  tree decl = cp_build_parm_decl (NULL_TREE, TREE_VALUE (args));
diff --git a/gcc/testsuite/g++.dg/template/typedef21.C b/gcc/testsuite/g++.dg/template/typedef21.C
new file mode 100644
index 0000000..3185331
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/typedef21.C
@@ -0,0 +1,11 @@
+// PR c++/37037
+typedef void F(void);
+template <typename T> struct S 
+    static F f;
+template class S<int>;
+template <class T> void S<T>::f(void)

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