[docs] Add LICENSE.txt to the root of the mono-repo
[llvm-project.git] / clang / test / Sema / builtin-assume.c
blob932fb5c973eb0e54cad8367ad84f0b6d9ba38db7
1 // RUN: %clang_cc1 -triple i386-mingw32 -fms-extensions -fsyntax-only -verify %s
2 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify %s
4 int nonconst(void);
5 int isconst(void) __attribute__((const));
6 int ispure(int) __attribute__((pure));
8 int foo(int *a, int i) {
9 #ifdef _MSC_VER
10 __assume(i != 4);
11 __assume(++i > 2); //expected-warning {{the argument to '__assume' has side effects that will be discarded}}
12 __assume(nonconst() > 2); //expected-warning {{the argument to '__assume' has side effects that will be discarded}}
13 __assume(isconst() > 2);
14 __assume(ispure(i) > 2);
15 __assume(ispure(++i) > 2); //expected-warning {{the argument to '__assume' has side effects that will be discarded}}
17 int test = sizeof(struct{char qq[(__assume(i != 5), 7)];});
18 #else
19 __builtin_assume(i != 4);
20 __builtin_assume(++i > 2); //expected-warning {{the argument to '__builtin_assume' has side effects that will be discarded}}
21 __builtin_assume(nonconst() > 2); //expected-warning {{the argument to '__builtin_assume' has side effects that will be discarded}}
22 __builtin_assume(isconst() > 2);
23 __builtin_assume(ispure(i) > 2);
24 __builtin_assume(ispure(++i) > 2); //expected-warning {{the argument to '__builtin_assume' has side effects that will be discarded}}
26 int test = sizeof(struct{char qq[(__builtin_assume(i != 5), 7)];}); // expected-warning {{variable length array}}
27 #endif
28 return a[i];