2014-07-17 22:25:55 +08:00
|
|
|
// RUN: %clang_cc1 -triple i386-mingw32 -fms-extensions -fsyntax-only -verify %s
|
2014-09-08 06:58:14 +08:00
|
|
|
// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify %s
|
2014-07-17 22:25:55 +08:00
|
|
|
|
2015-04-06 21:22:01 +08:00
|
|
|
int nonconst(void);
|
|
|
|
int isconst(void) __attribute__((const));
|
|
|
|
int ispure(int) __attribute__((pure));
|
|
|
|
|
2014-07-17 22:25:55 +08:00
|
|
|
int foo(int *a, int i) {
|
2014-09-08 06:58:14 +08:00
|
|
|
#ifdef _MSC_VER
|
2014-07-17 22:25:55 +08:00
|
|
|
__assume(i != 4);
|
2014-09-08 06:58:14 +08:00
|
|
|
__assume(++i > 2); //expected-warning {{the argument to '__assume' has side effects that will be discarded}}
|
2015-04-06 21:22:01 +08:00
|
|
|
__assume(nonconst() > 2); //expected-warning {{the argument to '__assume' has side effects that will be discarded}}
|
|
|
|
__assume(isconst() > 2);
|
|
|
|
__assume(ispure(i) > 2);
|
|
|
|
__assume(ispure(++i) > 2); //expected-warning {{the argument to '__assume' has side effects that will be discarded}}
|
2014-07-17 22:49:58 +08:00
|
|
|
|
|
|
|
int test = sizeof(struct{char qq[(__assume(i != 5), 7)];});
|
2014-09-08 06:58:14 +08:00
|
|
|
#else
|
|
|
|
__builtin_assume(i != 4);
|
|
|
|
__builtin_assume(++i > 2); //expected-warning {{the argument to '__builtin_assume' has side effects that will be discarded}}
|
2015-04-06 21:22:01 +08:00
|
|
|
__builtin_assume(nonconst() > 2); //expected-warning {{the argument to '__builtin_assume' has side effects that will be discarded}}
|
|
|
|
__builtin_assume(isconst() > 2);
|
|
|
|
__builtin_assume(ispure(i) > 2);
|
|
|
|
__builtin_assume(ispure(++i) > 2); //expected-warning {{the argument to '__builtin_assume' has side effects that will be discarded}}
|
|
|
|
|
2014-09-08 06:58:14 +08:00
|
|
|
int test = sizeof(struct{char qq[(__builtin_assume(i != 5), 7)];});
|
|
|
|
#endif
|
2014-07-17 22:25:55 +08:00
|
|
|
return a[i];
|
|
|
|
}
|
|
|
|
|