================ @@ -0,0 +1,126 @@ +// RUN: %clang_cc1 -fsyntax-only -verify=expected,c-local -x c %s +// RUN: %clang_cc1 -fsyntax-only -verify=expected,cpp-local -pedantic -x c++ -std=c++11 %s + +void foo() { + int i; + int a[10], b[10]; + + [[clang::code_align(8)]] + for (i = 0; i < 10; ++i) { // this is OK + a[i] = b[i] = 0; + } + // expected-error@+1{{'code_align' attribute only applies to 'for', 'while', and 'do' statements}} + [[clang::code_align(4)]] + i = 7; + for (i = 0; i < 10; ++i) { + a[i] = b[i] = 0; + } + + // expected-error@+1{{'code_align' attribute cannot be applied to a declaration}} + [[clang::code_align(12)]] int n[10]; +} + +void bar(int); +// cpp-local-note@+1{{declared here}} +void foo1(int A) +{ + // expected-error@+1{{'code_align' attribute requires an integer argument which is a constant power of two between 1 and 4096 inclusive; provided argument was 0}} + [[clang::code_align(0)]] + for(int I=0; I<128; ++I) { bar(I); } + + // expected-error@+1{{'code_align' attribute requires an integer argument which is a constant power of two between 1 and 4096 inclusive; provided argument was -4}} + [[clang::code_align(-4)]] + for(int I=0; I<128; ++I) { bar(I); } + + // cpp-local-error@+2{{integral constant expression must have integral or unscoped enumeration type, not 'double'}} + // c-local-error@+1{{integer constant expression must have integer type, not 'double'}} + [[clang::code_align(64.0)]] + for(int I=0; I<128; ++I) { bar(I); } + + // expected-error@+1{{'code_align' attribute takes one argument}} + [[clang::code_align()]] + for(int I=0; I<128; ++I) { bar(I); } + + // expected-error@+1{{'code_align' attribute takes one argument}} + [[clang::code_align(4,8)]] + for(int I=0; I<128; ++I) { bar(I); } + + // no diagnostic is expected + [[clang::code_align(32)]] + for(int I=0; I<128; ++I) { bar(I); } + + // cpp-local-error@+2{{integral constant expression must have integral or unscoped enumeration type, not 'const char[4]'}} + // c-local-error@+1{{integer constant expression must have integer type, not 'char[4]'}} + [[clang::code_align("abc")]] + for(int I=0; I<128; ++I) { bar(I); } + + [[clang::code_align(64)]] // expected-note{{previous attribute is here}} + [[clang::code_align(64)]] // expected-error{{duplicate loop attribute 'code_align'}} + for(int I=0; I<128; ++I) { bar(I); } + + // expected-error@+1{{'code_align' attribute requires an integer argument which is a constant power of two between 1 and 4096 inclusive; provided argument was 7}} + [[clang::code_align(7)]] + for(int I=0; I<128; ++I) { bar(I); } + + // expected-error@+1{{'code_align' attribute requires an integer argument which is a constant power of two between 1 and 4096 inclusive; provided argument was 5000}} + [[clang::code_align(5000)]] + for(int I=0; I<128; ++I) { bar(I); } + + // expected-warning@+2 {{integer literal is too large to be represented in a signed integer type, interpreting as unsigned}} + // expected-error@+1 {{'code_align' attribute requires an integer argument which is a constant power of two between 1 and 4096 inclusive; provided argument was 9223372036854775808}} + [[clang::code_align(9223372036854775808)]] + for(int I=0; I<256; ++I) { bar(I); } + + // expected-error@+1 {{'code_align' attribute requires an integer argument which is a constant power of two between 1 and 4096 inclusive; provided argument was 0}} ---------------- smanna12 wrote:
@erichkeane ,This is causing assertion instead of diagnostic Assertion failed: getActiveBits() <= 64 && "Too many bits for uint64_t", file C:\ws\src\llvm\include\llvm/ADT/APInt.h, line 1488 https://github.com/llvm/llvm-project/pull/70762 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits