From: Marek Polacek Date: Mon, 16 Mar 2015 18:30:49 +0000 (+0000) Subject: DR 1688 PR c++/65327 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ec638c5590b4e7c278c5b624c490fffad38bc639;p=gcc.git DR 1688 PR c++/65327 DR 1688 PR c++/65327 * decl.c (grokdeclarator): Allow volatile and constexpr together. * g++.dg/cpp0x/constexpr-object1.C: Change dg-error to dg-bogus. * g++.dg/cpp0x/pr65327.C: New test. From-SVN: r221463 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 259ce9c9839..b4fff5085e8 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2015-03-16 Marek Polacek + + DR 1688 + PR c++/65327 + * decl.c (grokdeclarator): Allow volatile and constexpr together. + 2015-03-12 Paolo Carlini PR c++/65323 diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index e35e48436dc..cb0f11f5749 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -10134,8 +10134,9 @@ grokdeclarator (const cp_declarator *declarator, the object as `const'. */ if (constexpr_p && innermost_code != cdk_function) { - if (type_quals & TYPE_QUAL_VOLATILE) - error ("both % and % cannot be used here"); + /* DR1688 says that a `constexpr' specifier in combination with + `volatile' is valid. */ + if (TREE_CODE (type) != REFERENCE_TYPE) { type_quals |= TYPE_QUAL_CONST; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a236581d4d6..9e10e2d94af 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2015-03-16 Marek Polacek + + DR 1688 + PR c++/65327 + * g++.dg/cpp0x/constexpr-object1.C: Change dg-error to dg-bogus. + * g++.dg/cpp0x/pr65327.C: New test. + 2015-03-16 Max Ostapenko PR sanitizer/64820 diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-object1.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-object1.C index 41afbe969a2..da9e3e4ab3f 100644 --- a/gcc/testsuite/g++.dg/cpp0x/constexpr-object1.C +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-object1.C @@ -19,7 +19,7 @@ constexpr A1 a2; // { dg-error "uninitialized const" } const constexpr A1 a3 = A1(); -volatile constexpr A1 a4 = A1(); // { dg-error "both .volatile. and .constexpr. cannot" } +volatile constexpr A1 a4 = A1(); // { dg-bogus "both .volatile. and .constexpr. cannot" } // error: on type declaration constexpr struct pixel diff --git a/gcc/testsuite/g++.dg/cpp0x/pr65327.C b/gcc/testsuite/g++.dg/cpp0x/pr65327.C new file mode 100644 index 00000000000..c6cefaba692 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr65327.C @@ -0,0 +1,18 @@ +// PR c++/65327 +// { dg-do compile { target c++11 } } +// DR1688 says that constexpr can be used together with volatile. + +constexpr volatile int i = 10; + +void +foo () +{ + constexpr volatile int j = 5; + static constexpr volatile int k = 5; +} + +constexpr volatile int +bar () +{ + return i; +}