[multiple changes]
authorDouglas Gregor <doug.gregor@gmail.com>
Wed, 28 Mar 2007 12:31:37 +0000 (12:31 +0000)
committerDoug Gregor <dgregor@gcc.gnu.org>
Wed, 28 Mar 2007 12:31:37 +0000 (12:31 +0000)
2007-03-28 Douglas Gregor <doug.gregor@gmail.com>

PR c++/29993
* decl.c (grokdeclarator): Deal with cv-qualified function type
typedefs in the same way for member and non-member functions.

2007-03-28  Douglas Gregor  <doug.gregor@gmail.com>

PR c++/29993
* g++.dg/other/cv_func2.C: New.

From-SVN: r123294

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/other/cv_func2.C [new file with mode: 0644]

index 13104a20e344d4524ecc4429349b7169215159c3..7541770c57959be6a3bb75ccb27363613e13d51a 100644 (file)
@@ -1,3 +1,9 @@
+2007-03-28 Douglas Gregor <doug.gregor@gmail.com>
+
+       PR c++/29993
+       * decl.c (grokdeclarator): Deal with cv-qualified function type
+       typedefs in the same way for member and non-member functions.
+
 2007-03-26  Dirk Mueller  <dmueller@suse.de>
 
        * parser.c (cp_parser_member_declaration): Pedwarn
index eefbba30c5d23d7e083b4144a6ff518ce945dba2..f107bee73ebd4cb156a97c2578f4a780e8942ab8 100644 (file)
@@ -8029,7 +8029,12 @@ grokdeclarator (const cp_declarator *declarator,
         member function of S.  We record the cv-qualification in the
         function type.  */
       if (memfn_quals && TREE_CODE (type) == FUNCTION_TYPE)
-       type = cp_build_qualified_type (type, memfn_quals);
+        {
+          type = cp_build_qualified_type (type, memfn_quals);
+          
+          /* We have now dealt with these qualifiers.  */
+          memfn_quals = TYPE_UNQUALIFIED;
+        }
 
       if (decl_context == FIELD)
        decl = build_lang_decl (TYPE_DECL, unqualified_id, type);
@@ -8091,11 +8096,6 @@ grokdeclarator (const cp_declarator *declarator,
             type with external linkage have external linkage.  */
        }
 
-       /* Any qualifiers on a function type typedef have already been
-          dealt with. */
-      if (memfn_quals && !ctype && TREE_CODE (type) == FUNCTION_TYPE)
-       memfn_quals = TYPE_UNQUALIFIED;
-
       if (signed_p
          || (typedef_decl && C_TYPEDEF_EXPLICITLY_SIGNED (typedef_decl)))
        C_TYPEDEF_EXPLICITLY_SIGNED (decl) = 1;
index 5457dfebfe835bce9e672cdfe815941919ffb99e..442ea61e1c1413f64e9d992c3f8f2ba267b56544 100644 (file)
@@ -1,3 +1,9 @@
+2007-03-28  Douglas Gregor  <doug.gregor@gmail.com>
+
+
+       PR c++/29993
+       * g++.dg/other/cv_func2.C: New.
+       
 2007-03-27  Janis Johnson  <janis187@us.ibm.com>
 
        * gcc.dg/dfp/func-vararg-alternate.h: New file.
diff --git a/gcc/testsuite/g++.dg/other/cv_func2.C b/gcc/testsuite/g++.dg/other/cv_func2.C
new file mode 100644 (file)
index 0000000..ffd249f
--- /dev/null
@@ -0,0 +1,18 @@
+typedef int ptr1() const; // no error
+
+void foo ()
+{
+  typedef int ptr2() const; // no error
+}
+
+class C
+{
+    typedef int ptr3() const;  // error
+
+    void bar ()
+      {
+        typedef int ptr4() const; // no error
+      }  
+};
+
+void wibble () const { } // { dg-error "non-member function" }