diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index f5fbb5cf7db..409e64d242c 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,8 @@ 2012-07-25 Jason Merrill + PR c++/54086 + * decl.c (grokdeclarator): Allow const and constexpr together. + PR c++/54020 * semantics.c (potential_constant_expression_1) [COND_EXPR]: Call maybe_constant_value. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index c37787bf929..047b2fea8b4 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -9528,8 +9528,6 @@ grokdeclarator (const cp_declarator *declarator, the object as `const'. */ if (constexpr_p && innermost_code != cdk_function) { - if (type_quals & TYPE_QUAL_CONST) - error ("both % and % cannot be used here"); if (type_quals & TYPE_QUAL_VOLATILE) error ("both % and % cannot be used here"); if (TREE_CODE (type) != REFERENCE_TYPE) diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-const1.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-const1.C new file mode 100644 index 00000000000..6ee72256e24 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-const1.C @@ -0,0 +1,7 @@ +// PR c++/54086 +// { dg-do compile { target c++11 } } + +static constexpr const char Data[] = { + 'D', 'A', 'T', 'A', +}; +static constexpr const char *data_func() { return Data; } diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-object1.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-object1.C index 4ff398bf1f0..6c9d4664418 100644 --- a/gcc/testsuite/g++.dg/cpp0x/constexpr-object1.C +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-object1.C @@ -18,8 +18,7 @@ extern constexpr int i2; // { dg-error "definition" } // error: missing initializer constexpr A1 a2; // { dg-error "uninitialized const" } -// error: duplicate cv -const constexpr A1 a3 = A1(); // { dg-error "both .const. and .constexpr. cannot" } +const constexpr A1 a3 = A1(); volatile constexpr A1 a4 = A1(); // { dg-error "both .volatile. and .constexpr. cannot" }