diff options
| author | Richard Smith <richard-llvm@metafoo.co.uk> | 2019-09-04 20:30:37 +0000 |
|---|---|---|
| committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2019-09-04 20:30:37 +0000 |
| commit | a6e8b685e13492abfb2e58dc49007deda165a00d (patch) | |
| tree | 279bbf503976a5c882db2f0699a858d10e66a5e9 /clang/test/Parser | |
| parent | eca01b031d44da54239d9956ba0acc7cf2f7798b (diff) | |
| download | bcm5719-llvm-a6e8b685e13492abfb2e58dc49007deda165a00d.tar.gz bcm5719-llvm-a6e8b685e13492abfb2e58dc49007deda165a00d.zip | |
[c++20] P1143R2: Add support for the C++20 'constinit' keyword.
This is mostly the same as the
[[clang::require_constant_initialization]] attribute, but has a couple
of additional syntactic and semantic restrictions.
In passing, I added a warning for the attribute form being added after
we have already seen the initialization of the variable (but before we
see the definition); that case previously slipped between the cracks and
the attribute was silently ignored.
llvm-svn: 370972
Diffstat (limited to 'clang/test/Parser')
| -rw-r--r-- | clang/test/Parser/cxx0x-decl.cpp | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/clang/test/Parser/cxx0x-decl.cpp b/clang/test/Parser/cxx0x-decl.cpp index 7bd82e8220b..2f219ac87fb 100644 --- a/clang/test/Parser/cxx0x-decl.cpp +++ b/clang/test/Parser/cxx0x-decl.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -verify -fsyntax-only -std=c++11 -pedantic-errors -triple x86_64-linux-gnu %s +// RUN: %clang_cc1 -verify -fsyntax-only -std=c++2a -pedantic-errors -triple x86_64-linux-gnu %s // Make sure we know these are legitimate commas and not typos for ';'. namespace Commas { @@ -108,14 +108,25 @@ namespace UsingDeclAttrs { } namespace DuplicateSpecifier { - constexpr constexpr int f(); // expected-warning {{duplicate 'constexpr' declaration specifier}} - constexpr int constexpr a = 0; // expected-warning {{duplicate 'constexpr' declaration specifier}} + constexpr constexpr int f(); // expected-error {{duplicate 'constexpr' declaration specifier}} + constexpr int constexpr a = 0; // expected-error {{duplicate 'constexpr' declaration specifier}} struct A { friend constexpr int constexpr friend f(); // expected-warning {{duplicate 'friend' declaration specifier}} \ - // expected-warning {{duplicate 'constexpr' declaration specifier}} + // expected-error {{duplicate 'constexpr' declaration specifier}} friend struct A friend; // expected-warning {{duplicate 'friend'}} expected-error {{'friend' must appear first}} }; + + constinit constexpr int n1 = 0; // expected-error {{cannot combine with previous 'constinit'}} + constexpr constinit int n2 = 0; // expected-error {{cannot combine with previous 'constexpr'}} + constinit constinit int n3 = 0; // expected-error {{duplicate 'constinit' declaration specifier}} + + consteval constexpr int f1(); // expected-error {{cannot combine with previous 'consteval'}} + constexpr consteval int f2(); // expected-error {{cannot combine with previous 'constexpr'}} + consteval consteval int f3(); // expected-error {{duplicate 'consteval' declaration specifier}} + + constinit consteval int wat = 0; // expected-error {{cannot combine with previous 'constinit'}} + consteval constinit int huh(); // expected-error {{cannot combine with previous 'consteval'}} } namespace ColonColonDecltype { |

