aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2011-05-21 18:01:38 -0400
committerJason Merrill <jason@gcc.gnu.org>2011-05-21 18:01:38 -0400
commitb6413764c0dd056f000c6541913e95af9bddbb3e (patch)
tree74f7a8762726bed8979bd2f80aee9f9a86f91c71
parent967444bbf8f78f46dd5df5c924a7650e4ad323ac (diff)
downloadgcc-b6413764c0dd056f000c6541913e95af9bddbb3e.zip
gcc-b6413764c0dd056f000c6541913e95af9bddbb3e.tar.gz
gcc-b6413764c0dd056f000c6541913e95af9bddbb3e.tar.bz2
re PR c++/48945 ([C++0x] static constexpr member function cannot be defined out-of class)
PR c++/48945 * decl.c (revert_static_member_fn): Ignore const on constexpr fn. From-SVN: r174006
-rw-r--r--gcc/cp/ChangeLog3
-rw-r--r--gcc/cp/decl.c9
-rw-r--r--gcc/testsuite/ChangeLog2
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/constexpr-static7.C8
4 files changed, 20 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 83c43e0..65479ea 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -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.
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index eae7d8e..598af1c 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -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;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 9cb673b..9e01b4e 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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
index 0000000..ba4a251
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-static7.C
@@ -0,0 +1,8 @@
+// PR c++/48945
+// { dg-options -std=c++0x }
+
+struct A {
+ static constexpr bool is();
+};
+
+constexpr bool A::is() { return true; }