diff options
Diffstat (limited to 'clang/test')
| -rw-r--r-- | clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/p3-0x.cpp | 3 | ||||
| -rw-r--r-- | clang/test/Parser/c1x-alignas.c | 7 | ||||
| -rw-r--r-- | clang/test/Parser/cxx0x-attributes.cpp | 6 | ||||
| -rw-r--r-- | clang/test/Sema/alignas.c | 19 | ||||
| -rw-r--r-- | clang/test/Sema/warn-cast-align.c | 2 | ||||
| -rw-r--r-- | clang/test/SemaCXX/attr-cxx0x.cpp | 12 |
6 files changed, 37 insertions, 12 deletions
diff --git a/clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/p3-0x.cpp b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/p3-0x.cpp index b93e8e35b13..9a2e4ab30c4 100644 --- a/clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/p3-0x.cpp +++ b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/p3-0x.cpp @@ -33,8 +33,7 @@ void f() { void g() throw (struct Ex {}) { // expected-error {{'Ex' can not be defined in a type specifier}} } -// FIXME: this currently gives a strange error because alignas is not recognised as a keyword yet. -int alignas(struct Aa {}) x; // expected-error {{'Aa' can not be defined in a parameter type}} expected-error {{expected function body}} +int alignas(struct Aa {}) x; // expected-error {{'Aa' can not be defined in a type specifier}} int a = sizeof(struct So {}); // expected-error {{'So' can not be defined in a type specifier}} int b = alignof(struct Ao {}); // expected-error {{'Ao' can not be defined in a type specifier}} diff --git a/clang/test/Parser/c1x-alignas.c b/clang/test/Parser/c1x-alignas.c new file mode 100644 index 00000000000..5dccc99035a --- /dev/null +++ b/clang/test/Parser/c1x-alignas.c @@ -0,0 +1,7 @@ +// RUN: %clang_cc1 -std=c1x -fsyntax-only -verify %s + +_Alignas(4) char c1; +unsigned _Alignas(long) char c2; +char _Alignas(16) c3; + +char c4 _Alignas(32); // expected-error {{expected ';' after top level declarator}} diff --git a/clang/test/Parser/cxx0x-attributes.cpp b/clang/test/Parser/cxx0x-attributes.cpp index 0b6413cfb27..94ea34d5035 100644 --- a/clang/test/Parser/cxx0x-attributes.cpp +++ b/clang/test/Parser/cxx0x-attributes.cpp @@ -6,7 +6,7 @@ int [[]] between_attr; int after_attr [[]]; int * [[]] ptr_attr; int array_attr [1] [[]]; -[[align(8)]] int aligned_attr; +alignas(8) int aligned_attr; [[test::valid(for 42 [very] **** '+' symbols went on a trip; the end.)]] int garbage_attr; void fn_attr () [[]]; @@ -32,8 +32,8 @@ extern "C++" [[]] { } // expected-error {{an attribute list cannot appear here}} [[]] using namespace ns; // Argument tests -[[align]] int aligned_no_params; // expected-error {{C++0x attribute 'align' must have an argument list}} -[[align(i)]] int aligned_nonconst; // expected-error {{'aligned' attribute requires integer constant}} +alignas int aligned_no_params; // expected-error {{expected '('}} +alignas(i) int aligned_nonconst; // expected-error {{'aligned' attribute requires integer constant}} // Statement tests void foo () { diff --git a/clang/test/Sema/alignas.c b/clang/test/Sema/alignas.c new file mode 100644 index 00000000000..5832393e3b6 --- /dev/null +++ b/clang/test/Sema/alignas.c @@ -0,0 +1,19 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -std=c1x %s + +_Alignas(3) int align_illegal; //expected-error {{requested alignment is not a power of 2}} +_Alignas(int) char align_big; +_Alignas(1) int align_small; // FIXME: this should be rejected +_Alignas(1) unsigned _Alignas(8) int _Alignas(1) align_multiple; + +struct align_member { + _Alignas(8) int member; +}; + +typedef _Alignas(8) char align_typedef; // FIXME: this should be rejected + +_Static_assert(__alignof(align_big) == __alignof(int), "k's alignment is wrong"); +_Static_assert(__alignof(align_small) == 1, "j's alignment is wrong"); +_Static_assert(__alignof(align_multiple) == 8, "l's alignment is wrong"); +_Static_assert(__alignof(struct align_member) == 8, "quuux's alignment is wrong"); +_Static_assert(sizeof(struct align_member) == 8, "quuux's size is wrong"); +_Static_assert(__alignof(align_typedef) == 8, "typedef's alignment is wrong"); diff --git a/clang/test/Sema/warn-cast-align.c b/clang/test/Sema/warn-cast-align.c index 11e3c416364..93352c253a2 100644 --- a/clang/test/Sema/warn-cast-align.c +++ b/clang/test/Sema/warn-cast-align.c @@ -28,7 +28,7 @@ void test1(void *P) { } // Aligned struct. -__attribute__((align(16))) struct A { +__attribute__((aligned(16))) struct A { char buffer[16]; }; void test2(char *P) { diff --git a/clang/test/SemaCXX/attr-cxx0x.cpp b/clang/test/SemaCXX/attr-cxx0x.cpp index 725f0182db5..ee5b2e57b59 100644 --- a/clang/test/SemaCXX/attr-cxx0x.cpp +++ b/clang/test/SemaCXX/attr-cxx0x.cpp @@ -1,15 +1,15 @@ // RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x %s -int align_illegal [[align(3)]]; //expected-error {{requested alignment is not a power of 2}} -char align_big [[align(int)]]; -int align_small [[align(1)]]; // FIXME: this should be rejected -int align_multiple [[align(1), align(8), align(1)]]; +int align_illegal alignas(3); //expected-error {{requested alignment is not a power of 2}} +char align_big alignas(int); +int align_small alignas(1); // FIXME: this should be rejected +int align_multiple alignas(1) alignas(8) alignas(1); struct align_member { - int member [[align(8)]]; + int member alignas(8); }; -typedef char align_typedef [[align(8)]]; +typedef char align_typedef alignas(8); template<typename T> using align_alias_template = align_typedef; static_assert(alignof(align_big) == alignof(int), "k's alignment is wrong"); |

