From 9ef0441c2e90e56dbc66a7728d3799e3131629d4 Mon Sep 17 00:00:00 2001 From: dgregor Date: Wed, 28 Mar 2007 12:31:37 +0000 Subject: [PATCH] 2007-03-28 Douglas Gregor 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 PR c++/29993 * g++.dg/other/cv_func2.C: New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@123294 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/decl.c | 12 ++++++------ gcc/testsuite/ChangeLog | 6 ++++++ gcc/testsuite/g++.dg/other/cv_func2.C | 18 ++++++++++++++++++ 4 files changed, 36 insertions(+), 6 deletions(-) create mode 100644 gcc/testsuite/g++.dg/other/cv_func2.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 13104a20e34..7541770c579 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2007-03-28 Douglas Gregor + + 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 * parser.c (cp_parser_member_declaration): Pedwarn diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index eefbba30c5d..f107bee73eb 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -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; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 5457dfebfe8..442ea61e1c1 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2007-03-28 Douglas Gregor + + + PR c++/29993 + * g++.dg/other/cv_func2.C: New. + 2007-03-27 Janis Johnson * 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 index 00000000000..ffd249fc807 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/cv_func2.C @@ -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" } -- 2.11.4.GIT