re PR c++/48945 ([C++0x] static constexpr member function cannot be defined out-of...
authorJason Merrill <jason@redhat.com>
Sat, 21 May 2011 22:01:38 +0000 (18:01 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Sat, 21 May 2011 22:01:38 +0000 (18:01 -0400)
PR c++/48945
* decl.c (revert_static_member_fn): Ignore const on constexpr fn.

From-SVN: r174006

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/constexpr-static7.C [new file with mode: 0644]

index 83c43e0243e2d84099f6f960a8d52ff6ca557d45..65479eabdc3ed1bab6e7c7a701e22608642e0719 100644 (file)
@@ -1,5 +1,8 @@
 2011-05-20  Jason Merrill  <jason@redhat.com>
 
+       PR c++/48945
+       * decl.c (revert_static_member_fn): Ignore const on constexpr fn.
+
        PR c++/48780
        * cvt.c (type_promotes_to): Don't promote scoped enums.
 
index eae7d8ec69b860322d7bb3c5398163d29bd2f3d6..598af1c482efa8ed4bf3604f63eb90c5a438b408 100644 (file)
@@ -13575,10 +13575,15 @@ void
 revert_static_member_fn (tree decl)
 {
   tree stype = static_fn_type (decl);
+  cp_cv_quals quals = type_memfn_quals (stype);
 
-  if (type_memfn_quals (stype) != TYPE_UNQUALIFIED)
+  if (quals != TYPE_UNQUALIFIED)
     {
-      error ("static member function %q#D declared with type qualifiers", decl);
+      if (quals == TYPE_QUAL_CONST && DECL_DECLARED_CONSTEXPR_P (decl))
+       /* The const was implicit, don't complain.  */;
+      else
+       error ("static member function %q#D declared with type qualifiers",
+              decl);
       stype = apply_memfn_quals (stype, TYPE_UNQUALIFIED);
     }
   TREE_TYPE (decl) = stype;
index 9cb673b143eb536c31fce546fdecb234bb988577..9e01b4e9813cc833e170df70d017dd95b85c64e4 100644 (file)
@@ -1,5 +1,7 @@
 2011-05-20  Jason Merrill  <jason@redhat.com>
 
+       * g++.dg/cpp0x/constexpr-static7.C: New.
+
        * g++.dg/cpp0x/enum12.C: New.
        * g++.dg/cpp0x/enum13.C: New.
 
diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-static7.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-static7.C
new file mode 100644 (file)
index 0000000..ba4a251
--- /dev/null
@@ -0,0 +1,8 @@
+// PR c++/48945
+// { dg-options -std=c++0x }
+
+struct A {
+  static constexpr bool is();
+};
+
+constexpr bool A::is() { return true; }