[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / Sema / inline-asm-validate-aarch64.c
blob1e753d40d8ca0eae3d6f78e310552f90eb7137eb
1 // RUN: %clang_cc1 -triple aarch64 -fsyntax-only -verify -DVERIFY %s
2 // RUN: %clang_cc1 -triple arm64-apple-darwin -fsyntax-only -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
4 typedef unsigned char uint8_t;
6 #ifdef VERIFY
7 void test_s(int i) {
8 asm("" :: "s"(i)); // expected-error{{invalid input constraint 's' in asm}}
10 /// Codegen error
11 asm("" :: "S"(i));
12 asm("" :: "S"(test_s(i))); // expected-error{{invalid type 'void' in asm input for constraint 'S'}}
14 #else
15 uint8_t constraint_r(uint8_t *addr) {
16 uint8_t byte;
18 __asm__ volatile("ldrb %0, [%1]" : "=r" (byte) : "r" (addr) : "memory");
19 // CHECK: warning: value size does not match register size specified by the constraint and modifier
20 // CHECK: note: use constraint modifier "w"
21 // CHECK: fix-it:{{.*}}:{[[#@LINE-3]]:26-[[#@LINE-3]]:28}:"%w0"
23 return byte;
26 uint8_t constraint_r_symbolic(uint8_t *addr) {
27 uint8_t byte;
29 __asm__ volatile("ldrb %[s0], [%[s1]]" : [s0] "=r" (byte) : [s1] "r" (addr) : "memory");
30 // CHECK: warning: value size does not match register size specified by the constraint and modifier
31 // CHECK: note: use constraint modifier "w"
32 // CHECK: fix-it:{{.*}}:{[[#@LINE-3]]:26-[[#@LINE-3]]:31}:"%w[s0]"
34 return byte;
37 #define PERCENT "%"
39 uint8_t constraint_r_symbolic_macro(uint8_t *addr) {
40 uint8_t byte;
42 __asm__ volatile("ldrb "PERCENT"[s0], [%[s1]]" : [s0] "=r" (byte) : [s1] "r" (addr) : "memory");
43 // CHECK: warning: value size does not match register size specified by the constraint and modifier
44 // CHECK: note: use constraint modifier "w"
45 // CHECK-NOT: fix-it
47 return byte;
50 // CHECK: warning: value size does not match register size specified by the constraint and modifier
51 // CHECK: asm ("%w0 %w1 %2" : "+r" (one) : "r" (wide_two));
52 // CHECK: note: use constraint modifier "w"
54 void read_write_modifier0(int one, int two) {
55 long wide_two = two;
56 asm ("%w0 %w1 %2" : "+r" (one) : "r" (wide_two));
57 // CHECK: fix-it:{{.*}}:{[[#@LINE-1]]:17-[[#@LINE-1]]:19}:"%w2"
60 // CHECK-NOT: warning:
61 void read_write_modifier1(int one, int two) {
62 long wide_two = two;
63 asm ("%w0 %1" : "+r" (one), "+r" (wide_two));
65 #endif