In C++11 we also need to allow function qualifiers in
alias-declarations, since they are equivalent to typedefs. There
doesn't seem to be any good reason for giving an error in grokdeclarator
at all, since we need to complain about uses of qualified function types
via typedef or template parameter anyway. But I'll make the small
change first so it's suitable for 4.8.
Tested x86_64-pc-linux-gnu, applying to trunk, will apply to 4.8 after
4.8.1.
commit c0931003b979bd016f8e2b507f9843c3e01e3fd1
Author: Jason Merrill <ja...@redhat.com>
Date: Tue May 14 17:07:11 2013 -0400
PR c++/57279
* decl.c (grokdeclarator): Allow member function qualifiers in
TYPENAME context.
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index b16472f..a4f686a 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -10295,8 +10295,10 @@ grokdeclarator (const cp_declarator *declarator,
if (ctype)
type = build_memfn_type (type, ctype, memfn_quals, rqual);
- /* Core issue #547: need to allow this in template type args. */
- else if (template_type_arg && TREE_CODE (type) == FUNCTION_TYPE)
+ /* Core issue #547: need to allow this in template type args.
+ Allow it in general in C++11 for alias-declarations. */
+ else if ((template_type_arg || cxx_dialect >= cxx11)
+ && TREE_CODE (type) == FUNCTION_TYPE)
type = apply_memfn_quals (type, memfn_quals, rqual);
else
error ("invalid qualifiers on non-member function type");
diff --git a/gcc/testsuite/g++.dg/cpp0x/alias-decl-35.C b/gcc/testsuite/g++.dg/cpp0x/alias-decl-35.C
new file mode 100644
index 0000000..f412b30
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/alias-decl-35.C
@@ -0,0 +1,9 @@
+// PR c++/57279
+// { dg-require-effective-target c++11 }
+
+typedef void fc1() const; // OK
+typedef void frr1() &&; // OK
+typedef void fcr1() const &;
+using fc2 = void() const; // #4
+using frr2 = void() &&; // OK
+using fcr2 = void() const &; // #6