// RUN: %clang_cc1 -std=c99 -fsyntax-only -verify %s // RUN: %clang_cc1 -x c++ -std=c++98 -fsyntax-only -verify %s // RUN: %clang_cc1 -std=c99 -fno-signed-char -fsyntax-only -verify %s struct A {}; typedef struct A *MPI_Datatype; int wrong1(void *buf, MPI_Datatype datatype) __attribute__(( pointer_with_type_tag )); // expected-error {{'pointer_with_type_tag' attribute requires parameter 1 to be an identifier}} int wrong2(void *buf, MPI_Datatype datatype) __attribute__(( pointer_with_type_tag(mpi,0,7) )); // expected-error {{attribute parameter 2 is out of bounds}} int wrong3(void *buf, MPI_Datatype datatype) __attribute__(( pointer_with_type_tag(mpi,3,7) )); // expected-error {{attribute parameter 2 is out of bounds}} int wrong4(void *buf, MPI_Datatype datatype) __attribute__(( pointer_with_type_tag(mpi,1,0) )); // expected-error {{attribute parameter 3 is out of bounds}} int wrong5(void *buf, MPI_Datatype datatype) __attribute__(( pointer_with_type_tag(mpi,1,3) )); // expected-error {{attribute parameter 3 is out of bounds}} int wrong6(void *buf, MPI_Datatype datatype) __attribute__(( pointer_with_type_tag(mpi,0x8000000000000001ULL,1) )); // expected-error {{attribute parameter 2 is out of bounds}} extern int x; int wrong7(void *buf, MPI_Datatype datatype) __attribute__(( pointer_with_type_tag(mpi,x,2) )); // expected-error {{attribute requires parameter 2 to be an integer constant}}
int a[((i128)-1 ^ (i128)-2) == 1 ? 1 : -1]; int a[(u128)-1 > 1LL ? 1 : -1]; int a[__SIZEOF_INT128__ == 16 ? 1 : -1]; // PR5435 __uint128_t b = (__uint128_t)-1; // PR11916: Support for libstdc++ 4.7 __int128 i = (__int128)0; unsigned __int128 u = (unsigned __int128)-1; long long SignedTooBig = 123456789012345678901234567890; // expected-error {{integer literal is too large to be represented in any integer type}} unsigned long long UnsignedTooBig = 123456789012345678901234567890; // expected-error {{integer literal is too large to be represented in any integer type}} void MPI_Send(void *buf, int datatype) __attribute__(( pointer_with_type_tag(mpi,1,2) )); static const int mpi_int __attribute__(( type_tag_for_datatype(mpi,int) )) = 10; void test(int *buf) { } #else __int128 n; // expected-error {{__int128 is not supported on this target}} #if defined(__SIZEOF_INT128__) #error __SIZEOF_INT128__ should not be defined #endif #endif
// CHECK-NEXT: DeclRefExpr{{.*}}mu1 class Mutex TestVariadicExpr __attribute__((acquired_after(mu1, mu2))); // CHECK: VarDecl{{.*}}TestVariadicExpr // CHECK: AcquiredAfterAttr // CHECK-NEXT: DeclRefExpr{{.*}}mu1 // CHECK-NEXT: DeclRefExpr{{.*}}mu2 void function1(void *) { int TestFunction __attribute__((cleanup(function1))); } // CHECK: VarDecl{{.*}}TestFunction // CHECK-NEXT: CleanupAttr{{.*}} Function{{.*}}function1 void TestIdentifier(void *, int) __attribute__((pointer_with_type_tag(ident1,1,2))); // CHECK: FunctionDecl{{.*}}TestIdentifier // CHECK: ArgumentWithTypeTagAttr{{.*}} ident1 void TestBool(void *, int) __attribute__((pointer_with_type_tag(bool1,1,2))); // CHECK: FunctionDecl{{.*}}TestBool // CHECK: ArgumentWithTypeTagAttr{{.*}} IsPointer void TestUnsigned(void *, int) __attribute__((pointer_with_type_tag(unsigned1,1,2))); // CHECK: FunctionDecl{{.*}}TestUnsigned // CHECK: ArgumentWithTypeTagAttr{{.*}} 0 1 void TestInt(void) __attribute__((constructor(123))); // CHECK: FunctionDecl{{.*}}TestInt
// RUN: %clang_cc1 -fsyntax-only -verify %s #define INT_TAG 42 static const int test_in __attribute__((type_tag_for_datatype(test, int))) = INT_TAG; // Argument index: 1, Type tag index: 2 void test_bounds_index(...) __attribute__((argument_with_type_tag(test, 1, 2))); // Argument index: 1, Type tag index: 2 void test_bounds_index_ptr(void *, ...) __attribute__((pointer_with_type_tag(test, 1, 2))); // Argument index: 3, Type tag index: 1 void test_bounds_arg_index(...) __attribute__((argument_with_type_tag(test, 3, 1))); class C { public: // Argument index: 2, Type tag index: 3 void test_bounds_index(...) __attribute__((argument_with_type_tag(test, 2, 3))); // Argument index: 2, Type tag index: 3 void test_bounds_index_ptr(void *, ...) __attribute__((pointer_with_type_tag(test, 2, 3))); // Argument index: 4, Type tag index: 2 void test_bounds_arg_index(...)