Commit 452ed9e7 by Jason Merrill Committed by Jason Merrill

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

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

From-SVN: r189852
parent 9155a6dd
2012-07-25 Jason Merrill <jason@redhat.com> 2012-07-25 Jason Merrill <jason@redhat.com>
PR c++/54086
* decl.c (grokdeclarator): Allow const and constexpr together.
PR c++/54020 PR c++/54020
* semantics.c (potential_constant_expression_1) [COND_EXPR]: Call * semantics.c (potential_constant_expression_1) [COND_EXPR]: Call
maybe_constant_value. maybe_constant_value.
......
...@@ -9528,8 +9528,6 @@ grokdeclarator (const cp_declarator *declarator, ...@@ -9528,8 +9528,6 @@ grokdeclarator (const cp_declarator *declarator,
the object as `const'. */ the object as `const'. */
if (constexpr_p && innermost_code != cdk_function) 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) if (type_quals & TYPE_QUAL_VOLATILE)
error ("both %<volatile%> and %<constexpr%> cannot be used here"); error ("both %<volatile%> and %<constexpr%> cannot be used here");
if (TREE_CODE (type) != REFERENCE_TYPE) if (TREE_CODE (type) != REFERENCE_TYPE)
......
// 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; }
...@@ -18,8 +18,7 @@ extern constexpr int i2; // { dg-error "definition" } ...@@ -18,8 +18,7 @@ extern constexpr int i2; // { dg-error "definition" }
// error: missing initializer // error: missing initializer
constexpr A1 a2; // { dg-error "uninitialized const" } constexpr A1 a2; // { dg-error "uninitialized const" }
// error: duplicate cv const constexpr A1 a3 = A1();
const constexpr A1 a3 = A1(); // { dg-error "both .const. and .constexpr. cannot" }
volatile constexpr A1 a4 = A1(); // { dg-error "both .volatile. and .constexpr. cannot" } volatile constexpr A1 a4 = A1(); // { dg-error "both .volatile. and .constexpr. cannot" }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment