1 // RUN: %clang_cc1 -triple i686 -fsyntax-only -verify %s
2 // RUN: %clang_cc1 -triple x86_64 -fsyntax-only -verify -DAMD64 %s
5 static const int BelowMin
= -1;
6 static const int AboveMax
= 32;
9 : "0"(i
), "I"(BelowMin
)); // expected-error{{value '-1' out of range for constraint 'I'}}
12 : "0"(i
), "I"(AboveMax
)); // expected-error{{value '32' out of range for constraint 'I'}}
15 : "0"(i
), "I"(16)); // expected-no-error
18 void J(int i
, int j
) {
19 static const int BelowMin
= -1;
20 static const int AboveMax
= 64;
23 : "0"(i
), "J"(BelowMin
)); // expected-error{{value '-1' out of range for constraint 'J'}}
26 : "0"(i
), "J"(AboveMax
)); // expected-error{{value '64' out of range for constraint 'J'}}
29 : "0"(i
), "J"(32)); // expected-no-error
32 void K(int i
, int j
) {
33 static const int BelowMin
= -129;
34 static const int AboveMax
= 128;
37 : "0"(i
), "K"(BelowMin
)); // expected-error{{value '-129' out of range for constraint 'K'}}
40 : "0"(i
), "K"(AboveMax
)); // expected-error{{value '128' out of range for constraint 'K'}}
43 : "0"(i
), "K"(96)); // expected-no-error
46 void L(int i
, int j
) {
47 static const int Invalid1
= 1;
48 static const int Invalid2
= 42;
49 static const int Invalid3
= 0;
50 static const long long Invalid4
= 0x1000000ff;
51 static const int Valid1
= 0xff;
52 static const int Valid2
= 0xffff;
53 static const int Valid3
= 0xffffffff;
56 : "0"(i
), "L"(Invalid1
)); // expected-error{{value '1' out of range for constraint 'L'}}
59 : "0"(i
), "L"(Invalid2
)); // expected-error{{value '42' out of range for constraint 'L'}}
62 : "0"(i
), "L"(Invalid3
)); // expected-error{{value '0' out of range for constraint 'L'}}
65 : "0"(i
), "L"(Invalid4
)); // expected-error{{value '4294967551' out of range for constraint 'L'}}
68 : "0"(i
), "L"(Valid1
)); // expected-no-error
71 : "0"(i
), "L"(Valid2
)); // expected-no-error
74 : "0"(i
), "L"(Valid3
)); // expected-no-error
77 void M(int i
, int j
) {
78 static const int BelowMin
= -1;
79 static const int AboveMax
= 4;
82 : "0"(i
), "M"(BelowMin
)); // expected-error{{value '-1' out of range for constraint 'M'}}
85 : "0"(i
), "M"(AboveMax
)); // expected-error{{value '4' out of range for constraint 'M'}}
88 : "0"(i
), "M"(2)); // expected-no-error
91 void N(int i
, int j
) {
92 static const int BelowMin
= -1;
93 static const int AboveMax
= 256;
96 : "0"(i
), "N"(BelowMin
)); // expected-error{{value '-1' out of range for constraint 'N'}}
99 : "0"(i
), "N"(AboveMax
)); // expected-error{{value '256' out of range for constraint 'N'}}
102 : "0"(i
), "N"(128)); // expected-no-error
105 void O(int i
, int j
) {
106 static const int BelowMin
= -1;
107 static const int AboveMax
= 128;
110 : "0"(i
), "O"(BelowMin
)); // expected-error{{value '-1' out of range for constraint 'O'}}
113 : "0"(i
), "O"(AboveMax
)); // expected-error{{value '128' out of range for constraint 'O'}}
116 : "0"(i
), "O"(64)); // expected-no-error
124 // This null pointer can be used as an integer constant expression.
125 __asm__
__volatile__("\n#define S_A abcd%0\n" : : "n"(&((struct s
*)0)->a
));
126 // This offset-from-null pointer can be used as an integer constant expression.
127 __asm__
__volatile__("\n#define S_B abcd%0\n" : : "n"(&((struct s
*)0)->b
));
129 // This arbitrary pointer is fine.
130 __asm__
__volatile__("\n#define BEEF abcd%0\n" : : "n"((int*)0xdeadbeeeeeef));