blob: 43b31375f20017d5f549944ea4c505486f004a9e [file] [log] [blame]
Hal Finkelf0417332014-07-17 14:25:55 +00001// RUN: %clang_cc1 -triple i386-mingw32 -fms-extensions -fsyntax-only -verify %s
Hal Finkelbcc06082014-09-07 22:58:14 +00002// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify %s
Hal Finkelf0417332014-07-17 14:25:55 +00003
Michael Kupersteinaed5ccd2015-04-06 13:22:01 +00004int nonconst(void);
5int isconst(void) __attribute__((const));
6int ispure(int) __attribute__((pure));
7
Hal Finkelf0417332014-07-17 14:25:55 +00008int foo(int *a, int i) {
Hal Finkelbcc06082014-09-07 22:58:14 +00009#ifdef _MSC_VER
Hal Finkelf0417332014-07-17 14:25:55 +000010 __assume(i != 4);
Hal Finkelbcc06082014-09-07 22:58:14 +000011 __assume(++i > 2); //expected-warning {{the argument to '__assume' has side effects that will be discarded}}
Michael Kupersteinaed5ccd2015-04-06 13:22:01 +000012 __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}}
Hal Finkela8443c32014-07-17 14:49:58 +000016
17 int test = sizeof(struct{char qq[(__assume(i != 5), 7)];});
Hal Finkelbcc06082014-09-07 22:58:14 +000018#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}}
Michael Kupersteinaed5ccd2015-04-06 13:22:01 +000021 __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}}
25
Hal Finkelbcc06082014-09-07 22:58:14 +000026 int test = sizeof(struct{char qq[(__builtin_assume(i != 5), 7)];});
27#endif
Hal Finkelf0417332014-07-17 14:25:55 +000028 return a[i];
29}
30