Hal Finkel | f041733 | 2014-07-17 14:25:55 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -triple i386-mingw32 -fms-extensions -fsyntax-only -verify %s |
Hal Finkel | bcc0608 | 2014-09-07 22:58:14 +0000 | [diff] [blame] | 2 | // RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify %s |
Hal Finkel | f041733 | 2014-07-17 14:25:55 +0000 | [diff] [blame] | 3 | |
Michael Kuperstein | aed5ccd | 2015-04-06 13:22:01 +0000 | [diff] [blame^] | 4 | int nonconst(void); |
| 5 | int isconst(void) __attribute__((const)); |
| 6 | int ispure(int) __attribute__((pure)); |
| 7 | |
Hal Finkel | f041733 | 2014-07-17 14:25:55 +0000 | [diff] [blame] | 8 | int foo(int *a, int i) { |
Hal Finkel | bcc0608 | 2014-09-07 22:58:14 +0000 | [diff] [blame] | 9 | #ifdef _MSC_VER |
Hal Finkel | f041733 | 2014-07-17 14:25:55 +0000 | [diff] [blame] | 10 | __assume(i != 4); |
Hal Finkel | bcc0608 | 2014-09-07 22:58:14 +0000 | [diff] [blame] | 11 | __assume(++i > 2); //expected-warning {{the argument to '__assume' has side effects that will be discarded}} |
Michael Kuperstein | aed5ccd | 2015-04-06 13:22:01 +0000 | [diff] [blame^] | 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}} |
Hal Finkel | a8443c3 | 2014-07-17 14:49:58 +0000 | [diff] [blame] | 16 | |
| 17 | int test = sizeof(struct{char qq[(__assume(i != 5), 7)];}); |
Hal Finkel | bcc0608 | 2014-09-07 22:58:14 +0000 | [diff] [blame] | 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}} |
Michael Kuperstein | aed5ccd | 2015-04-06 13:22:01 +0000 | [diff] [blame^] | 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}} |
| 25 | |
Hal Finkel | bcc0608 | 2014-09-07 22:58:14 +0000 | [diff] [blame] | 26 | int test = sizeof(struct{char qq[(__builtin_assume(i != 5), 7)];}); |
| 27 | #endif |
Hal Finkel | f041733 | 2014-07-17 14:25:55 +0000 | [diff] [blame] | 28 | return a[i]; |
| 29 | } |
| 30 | |