From 6f640d1576d109cb13898a449fa84619e7a50ad4 Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Mon, 25 Nov 2013 16:10:29 +0000 Subject: [PATCH] re PR c++/58810 (ICE with invalid function typedef) /cp 2013-11-25 Paolo Carlini PR c++/58810 * decl.c (grokdeclarator): Don't handle qualified free functions here, leave the diagnostic to grokfndecl. /testsuite 2013-11-25 Paolo Carlini PR c++/58810 * g++.dg/other/cv_func3.C: New. * g++.dg/other/cv_func.C: Adjust. * g++.dg/parse/fn-typedef2.C: Likewise. From-SVN: r205356 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/decl.c | 15 --------------- gcc/testsuite/ChangeLog | 13 ++++++++++--- gcc/testsuite/g++.dg/other/cv_func.C | 2 +- gcc/testsuite/g++.dg/other/cv_func3.C | 10 ++++++++++ gcc/testsuite/g++.dg/parse/fn-typedef2.C | 2 +- 6 files changed, 28 insertions(+), 20 deletions(-) create mode 100644 gcc/testsuite/g++.dg/other/cv_func3.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 74b75e9891c..8118471f60f 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2013-11-25 Paolo Carlini + + PR c++/58810 + * decl.c (grokdeclarator): Don't handle qualified free functions here, + leave the diagnostic to grokfndecl. + 2013-11-25 Paolo Carlini PR c++/59080 diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 889c203b1f1..75e29f4bfa2 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -10256,21 +10256,6 @@ grokdeclarator (const cp_declarator *declarator, if (decl_context != TYPENAME) { - /* A cv-qualifier-seq shall only be part of the function type - for a non-static member function. A ref-qualifier shall only - .... /same as above/ [dcl.fct] */ - if ((type_memfn_quals (type) != TYPE_UNQUALIFIED - || type_memfn_rqual (type) != REF_QUAL_NONE) - && (current_class_type == NULL_TREE || staticp) ) - { - error (staticp - ? G_("qualified function types cannot be used to " - "declare static member functions") - : G_("qualified function types cannot be used to " - "declare free functions")); - type = TYPE_MAIN_VARIANT (type); - } - /* The qualifiers on the function type become the qualifiers on the non-static member function. */ memfn_quals |= type_memfn_quals (type); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index c0bd2b15d7c..50e72f4c880 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2013-11-25 Paolo Carlini + + PR c++/58810 + * g++.dg/other/cv_func3.C: New. + * g++.dg/other/cv_func.C: Adjust. + * g++.dg/parse/fn-typedef2.C: Likewise. + 2013-11-25 Marek Polacek PR sanitizer/59250 @@ -20,9 +27,9 @@ PR c++/59112 PR c++/59113 - g++.dg/cpp1y/pr58533.C: Updated testcase. - g++.dg/cpp1y/pr59112.C: New testcase. - g++.dg/cpp1y/pr59113.C: New testcase. + * g++.dg/cpp1y/pr58533.C: Updated testcase. + * g++.dg/cpp1y/pr59112.C: New testcase. + * g++.dg/cpp1y/pr59113.C: New testcase. 2013-11-25 Terry Guo diff --git a/gcc/testsuite/g++.dg/other/cv_func.C b/gcc/testsuite/g++.dg/other/cv_func.C index 941cb8d53d8..2eb9f039a5a 100644 --- a/gcc/testsuite/g++.dg/other/cv_func.C +++ b/gcc/testsuite/g++.dg/other/cv_func.C @@ -3,7 +3,7 @@ typedef int FIC(int) const; typedef int FI(int); -FIC f; // { dg-error "qualified" } +FIC f; // { dg-error "cv-qualifier" } struct S { FIC f; // OK diff --git a/gcc/testsuite/g++.dg/other/cv_func3.C b/gcc/testsuite/g++.dg/other/cv_func3.C new file mode 100644 index 00000000000..0fd47882f2a --- /dev/null +++ b/gcc/testsuite/g++.dg/other/cv_func3.C @@ -0,0 +1,10 @@ +// PR c++/58810 + +typedef int F() const; + +F f; // { dg-error "cv-qualifier" } + +struct A +{ + friend F f; // { dg-error "cv-qualifier" } +}; diff --git a/gcc/testsuite/g++.dg/parse/fn-typedef2.C b/gcc/testsuite/g++.dg/parse/fn-typedef2.C index c9c7f060d01..6bb83024b9f 100644 --- a/gcc/testsuite/g++.dg/parse/fn-typedef2.C +++ b/gcc/testsuite/g++.dg/parse/fn-typedef2.C @@ -4,4 +4,4 @@ typedef void ft() const; typedef void V; typedef V ft() const; -ft f; // { dg-error "qualified" } +ft f; // { dg-error "cv-qualifier" }