1// RUN: %clang_cc1 -triple i686 -fsyntax-only -verify %s
2// RUN: %clang_cc1 -triple x86_64 -fsyntax-only -verify %s
3
4void I(int i, int j) {
5  static const int BelowMin = -1;
6  static const int AboveMax = 32;
7  __asm__("xorl %0,%2"
8          : "=r"(i)
9          : "0"(i), "I"(j)); // expected-error{{constraint 'I' expects an integer constant expression}}
10  __asm__("xorl %0,%2"
11          : "=r"(i)
12          : "0"(i), "I"(BelowMin)); // expected-error{{value '-1' out of range for constraint 'I'}}
13  __asm__("xorl %0,%2"
14          : "=r"(i)
15          : "0"(i), "I"(AboveMax)); // expected-error{{value '32' out of range for constraint 'I'}}
16  __asm__("xorl %0,%2"
17          : "=r"(i)
18          : "0"(i), "I"(16)); // expected-no-error
19}
20
21void J(int i, int j) {
22  static const int BelowMin = -1;
23  static const int AboveMax = 64;
24  __asm__("xorl %0,%2"
25          : "=r"(i)
26          : "0"(i), "J"(j)); // expected-error{{constraint 'J' expects an integer constant expression}}
27  __asm__("xorl %0,%2"
28          : "=r"(i)
29          : "0"(i), "J"(BelowMin)); // expected-error{{value '-1' out of range for constraint 'J'}}
30  __asm__("xorl %0,%2"
31          : "=r"(i)
32          : "0"(i), "J"(AboveMax)); // expected-error{{value '64' out of range for constraint 'J'}}
33  __asm__("xorl %0,%2"
34          : "=r"(i)
35          : "0"(i), "J"(32)); // expected-no-error
36}
37
38void K(int i, int j) {
39  static const int BelowMin = -129;
40  static const int AboveMax = 128;
41  __asm__("xorl %0,%2"
42          : "=r"(i)
43          : "0"(i), "K"(j)); // expected-error{{constraint 'K' expects an integer constant expression}}
44  __asm__("xorl %0,%2"
45          : "=r"(i)
46          : "0"(i), "K"(BelowMin)); // expected-error{{value '-129' out of range for constraint 'K'}}
47  __asm__("xorl %0,%2"
48          : "=r"(i)
49          : "0"(i), "K"(AboveMax)); // expected-error{{value '128' out of range for constraint 'K'}}
50  __asm__("xorl %0,%2"
51          : "=r"(i)
52          : "0"(i), "K"(96)); // expected-no-error
53}
54
55void L(int i, int j) {
56  static const int Invalid1 = 1;
57  static const int Invalid2 = 42;
58  static const int Valid1 = 0xff;
59  static const int Valid2 = 0xffff;
60  static const int Valid3 = 0xffffffff;
61  __asm__("xorl %0,%2"
62          : "=r"(i)
63          : "0"(i), "L"(j)); // expected-error{{constraint 'L' expects an integer constant expression}}
64  __asm__("xorl %0,%2"
65          : "=r"(i)
66          : "0"(i), "L"(Invalid1)); // expected-error{{value '1' out of range for constraint 'L'}}
67  __asm__("xorl %0,%2"
68          : "=r"(i)
69          : "0"(i), "L"(Invalid2)); // expected-error{{value '42' out of range for constraint 'L'}}
70  __asm__("xorl %0,%2"
71          : "=r"(i)
72          : "0"(i), "L"(Valid1)); // expected-no-error
73  __asm__("xorl %0,%2"
74          : "=r"(i)
75          : "0"(i), "L"(Valid2)); // expected-no-error
76  __asm__("xorl %0,%2"
77          : "=r"(i)
78          : "0"(i), "L"(Valid3)); // expected-no-error
79}
80
81void M(int i, int j) {
82  static const int BelowMin = -1;
83  static const int AboveMax = 4;
84  __asm__("xorl %0,%2"
85          : "=r"(i)
86          : "0"(i), "M"(j)); // expected-error{{constraint 'M' expects an integer constant expression}}
87  __asm__("xorl %0,%2"
88          : "=r"(i)
89          : "0"(i), "M"(BelowMin)); // expected-error{{value '-1' out of range for constraint 'M'}}
90  __asm__("xorl %0,%2"
91          : "=r"(i)
92          : "0"(i), "M"(AboveMax)); // expected-error{{value '4' out of range for constraint 'M'}}
93  __asm__("xorl %0,%2"
94          : "=r"(i)
95          : "0"(i), "M"(2)); // expected-no-error
96}
97
98void N(int i, int j) {
99  static const int BelowMin = -1;
100  static const int AboveMax = 256;
101  __asm__("xorl %0,%2"
102          : "=r"(i)
103          : "0"(i), "N"(j)); // expected-error{{constraint 'N' expects an integer constant expression}}
104  __asm__("xorl %0,%2"
105          : "=r"(i)
106          : "0"(i), "N"(BelowMin)); // expected-error{{value '-1' out of range for constraint 'N'}}
107  __asm__("xorl %0,%2"
108          : "=r"(i)
109          : "0"(i), "N"(AboveMax)); // expected-error{{value '256' out of range for constraint 'N'}}
110  __asm__("xorl %0,%2"
111          : "=r"(i)
112          : "0"(i), "N"(128)); // expected-no-error
113}
114
115void O(int i, int j) {
116  static const int BelowMin = -1;
117  static const int AboveMax = 128;
118  __asm__("xorl %0,%2"
119          : "=r"(i)
120          : "0"(i), "O"(j)); // expected-error{{constraint 'O' expects an integer constant expression}}
121  __asm__("xorl %0,%2"
122          : "=r"(i)
123          : "0"(i), "O"(BelowMin)); // expected-error{{value '-1' out of range for constraint 'O'}}
124  __asm__("xorl %0,%2"
125          : "=r"(i)
126          : "0"(i), "O"(AboveMax)); // expected-error{{value '128' out of range for constraint 'O'}}
127  __asm__("xorl %0,%2"
128          : "=r"(i)
129          : "0"(i), "O"(64)); // expected-no-error
130}
131
132