| 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 |
| 3 |
|
| 4 |
int nonconst(void); |
| 5 |
int isconst(void) __attribute__((const)); |
| 6 |
int ispure(int) __attribute__((pure)); |
| 7 |
|
| 8 |
int foo(int *a, int i) { |
| 9 |
#ifdef _MSC_VER |
| 10 |
__assume(i != 4); |
| 11 |
__assume(++i > 2); //expected-warning {{assumption is ignored because it contains (potential) side-effects}} |
| 12 |
__assume(nonconst() > 2); //expected-warning {{assumption is ignored because it contains (potential) side-effects}} |
| 13 |
__assume(isconst() > 2); |
| 14 |
__assume(ispure(i) > 2); |
| 15 |
__assume(ispure(++i) > 2); //expected-warning {{assumption is ignored because it contains (potential) side-effects}} |
| 16 |
|
| 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 {{assumption is ignored because it contains (potential) side-effects}} |
| 21 |
__builtin_assume(nonconst() > 2); //expected-warning {{assumption is ignored because it contains (potential) side-effects}} |
| 22 |
__builtin_assume(isconst() > 2); |
| 23 |
__builtin_assume(ispure(i) > 2); |
| 24 |
__builtin_assume(ispure(++i) > 2); //expected-warning {{assumption is ignored because it contains (potential) side-effects}} |
| 25 |
|
| 26 |
int test = sizeof(struct{char qq[(__builtin_assume(i != 5), 7)];}); // expected-warning {{variable length array}} |
| 27 |
#endif |
| 28 |
return a[i]; |
| 29 |
} |
| 30 |
|