From: Douglas Gregor Date: Wed, 28 Mar 2007 12:31:37 +0000 (+0000) Subject: [multiple changes] X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=771026dd0ccaad37e4af85be52f6bc15a47da194;p=gcc.git [multiple changes] 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. From-SVN: r123294 --- 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" }