... this is an alternate, more conservative approach: a check remains in
grokdeclarator and it handles friends too. At variance with the check in
grokfndecl it's about function *types*.
Thanks,
Paolo.
///////////////////////
Index: cp/decl.c
===================================================================
--- cp/decl.c (revision 203907)
+++ cp/decl.c (working copy)
@@ -10247,7 +10247,7 @@ grokdeclarator (const cp_declarator *declarator,
.... /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) )
+ && (current_class_type == NULL_TREE || staticp || friendp) )
{
error (staticp
? G_("qualified function types cannot be used to "
Index: testsuite/g++.dg/other/cv_func3.C
===================================================================
--- testsuite/g++.dg/other/cv_func3.C (revision 0)
+++ testsuite/g++.dg/other/cv_func3.C (working copy)
@@ -0,0 +1,10 @@
+// PR c++/58810
+
+typedef int F() const;
+
+F f; // { dg-error "qualified" }
+
+struct A
+{
+ friend F f; // { dg-error "qualified" }
+};