OSDN Git Service

PR c++/54086
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 10 Sep 2012 14:23:54 +0000 (14:23 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 10 Sep 2012 14:23:54 +0000 (14:23 +0000)
* decl.c (grokdeclarator): Allow const and constexpr together.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_7-branch@191144 138bc75d-0d04-0410-961f-82ee72b054a4

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

index 458a276..137553f 100644 (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
index 572efcd..bd6efd9 100644 (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)
diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-const1.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-const1.C
new file mode 100644 (file)
index 0000000..6ee7225
--- /dev/null
@@ -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; }
index 4ff398b..6c9d466 100644 (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" }