re PR c++/54086 (GCC should allow constexpr and const together)

PR c++/54086
	* decl.c (grokdeclarator): Allow const and constexpr together.

From-SVN: r191144
This commit is contained in:
Jason Merrill 2012-09-10 10:23:54 -04:00 committed by Jason Merrill
parent 63db577f5d
commit c03a696624
4 changed files with 13 additions and 4 deletions

View File

@ -1,3 +1,8 @@
2012-09-10 Jason Merrill <jason@redhat.com>
PR c++/54086
* decl.c (grokdeclarator): Allow const and constexpr together.
2012-08-31 Ollie Wild <aaw@google.com>
PR c++/54197

View File

@ -9493,8 +9493,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 %<const%> and %<constexpr%> cannot be used here");
if (type_quals & TYPE_QUAL_VOLATILE)
error ("both %<volatile%> and %<constexpr%> cannot be used here");
if (TREE_CODE (type) != REFERENCE_TYPE)

View File

@ -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; }

View File

@ -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" }