brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.8 KiB · d4c10c3 Raw
141 lines · c
1// RUN: %clang_cc1 -triple i686 -fsyntax-only -verify %s2// RUN: %clang_cc1 -triple x86_64 -fsyntax-only -verify -DAMD64 %s3 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"(BelowMin)); // expected-error{{value '-1' out of range for constraint 'I'}}10  __asm__("xorl %0,%2"11          : "=r"(i)12          : "0"(i), "I"(AboveMax)); // expected-error{{value '32' out of range for constraint 'I'}}13  __asm__("xorl %0,%2"14          : "=r"(i)15          : "0"(i), "I"(16)); // expected-no-error16}17 18void J(int i, int j) {19  static const int BelowMin = -1;20  static const int AboveMax = 64;21  __asm__("xorl %0,%2"22          : "=r"(i)23          : "0"(i), "J"(BelowMin)); // expected-error{{value '-1' out of range for constraint 'J'}}24  __asm__("xorl %0,%2"25          : "=r"(i)26          : "0"(i), "J"(AboveMax)); // expected-error{{value '64' out of range for constraint 'J'}}27  __asm__("xorl %0,%2"28          : "=r"(i)29          : "0"(i), "J"(32)); // expected-no-error30}31 32void K(int i, int j) {33  static const int BelowMin = -129;34  static const int AboveMax = 128;35  __asm__("xorl %0,%2"36          : "=r"(i)37          : "0"(i), "K"(BelowMin)); // expected-error{{value '-129' out of range for constraint 'K'}}38  __asm__("xorl %0,%2"39          : "=r"(i)40          : "0"(i), "K"(AboveMax)); // expected-error{{value '128' out of range for constraint 'K'}}41  __asm__("xorl %0,%2"42          : "=r"(i)43          : "0"(i), "K"(96)); // expected-no-error44}45 46void 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;54  __asm__("xorl %0,%2"55          : "=r"(i)56          : "0"(i), "L"(Invalid1)); // expected-error{{value '1' out of range for constraint 'L'}}57  __asm__("xorl %0,%2"58          : "=r"(i)59          : "0"(i), "L"(Invalid2)); // expected-error{{value '42' out of range for constraint 'L'}}60  __asm__("xorl %0,%2"61          : "=r"(i)62          : "0"(i), "L"(Invalid3)); // expected-error{{value '0' out of range for constraint 'L'}}63  __asm__("xorl %0,%2"64          : "=r"(i)65          : "0"(i), "L"(Invalid4)); // expected-error{{value '4294967551' out of range for constraint 'L'}}66  __asm__("xorl %0,%2"67          : "=r"(i)68          : "0"(i), "L"(Valid1)); // expected-no-error69  __asm__("xorl %0,%2"70          : "=r"(i)71          : "0"(i), "L"(Valid2)); // expected-no-error72  __asm__("xorl %0,%2"73          : "=r"(i)74          : "0"(i), "L"(Valid3)); // expected-no-error75}76 77void M(int i, int j) {78  static const int BelowMin = -1;79  static const int AboveMax = 4;80  __asm__("xorl %0,%2"81          : "=r"(i)82          : "0"(i), "M"(BelowMin)); // expected-error{{value '-1' out of range for constraint 'M'}}83  __asm__("xorl %0,%2"84          : "=r"(i)85          : "0"(i), "M"(AboveMax)); // expected-error{{value '4' out of range for constraint 'M'}}86  __asm__("xorl %0,%2"87          : "=r"(i)88          : "0"(i), "M"(2)); // expected-no-error89}90 91void N(int i, int j) {92  static const int BelowMin = -1;93  static const int AboveMax = 256;94  __asm__("xorl %0,%2"95          : "=r"(i)96          : "0"(i), "N"(BelowMin)); // expected-error{{value '-1' out of range for constraint 'N'}}97  __asm__("xorl %0,%2"98          : "=r"(i)99          : "0"(i), "N"(AboveMax)); // expected-error{{value '256' out of range for constraint 'N'}}100  __asm__("xorl %0,%2"101          : "=r"(i)102          : "0"(i), "N"(128)); // expected-no-error103}104 105void O(int i, int j) {106  static const int BelowMin = -1;107  static const int AboveMax = 128;108  __asm__("xorl %0,%2"109          : "=r"(i)110          : "0"(i), "O"(BelowMin)); // expected-error{{value '-1' out of range for constraint 'O'}}111  __asm__("xorl %0,%2"112          : "=r"(i)113          : "0"(i), "O"(AboveMax)); // expected-error{{value '128' out of range for constraint 'O'}}114  __asm__("xorl %0,%2"115          : "=r"(i)116          : "0"(i), "O"(64)); // expected-no-error117}118 119void pr40890(void) {120  struct s {121    int a, b;122  };123  static struct s s;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));128#ifdef AMD64129  // This arbitrary pointer is fine.130  __asm__ __volatile__("\n#define BEEF abcd%0\n" : : "n"((int*)0xdeadbeeeeeef));131#endif132}133 134void test_W(int i) {135  __asm__("" : : "Wd"(test_W)); // expected-error{{invalid input constraint 'Wd' in asm}}136 137  __asm__("" : : "Ws"(test_W(0))); // expected-error{{invalid type 'void' in asm input for constraint 'Ws'}}138  // Codegen error139  __asm__("" : : "Ws"(i));140}141