Akira Hatanaka | 987f186 | 2014-08-22 06:05:21 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -triple arm64-apple-darwin -fsyntax-only -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s |
| 2 | |
| 3 | typedef unsigned char uint8_t; |
| 4 | |
| 5 | uint8_t constraint_r(uint8_t *addr) { |
| 6 | uint8_t byte; |
| 7 | |
| 8 | __asm__ volatile("ldrb %0, [%1]" : "=r" (byte) : "r" (addr) : "memory"); |
| 9 | // CHECK: warning: value size does not match register size specified by the constraint and modifier |
| 10 | // CHECK: note: use constraint modifier "w" |
| 11 | // CHECK: fix-it:{{.*}}:{8:26-8:28}:"%w0" |
| 12 | |
| 13 | return byte; |
| 14 | } |
| 15 | |
| 16 | uint8_t constraint_r_symbolic(uint8_t *addr) { |
| 17 | uint8_t byte; |
| 18 | |
| 19 | __asm__ volatile("ldrb %[s0], [%[s1]]" : [s0] "=r" (byte) : [s1] "r" (addr) : "memory"); |
| 20 | // CHECK: warning: value size does not match register size specified by the constraint and modifier |
| 21 | // CHECK: note: use constraint modifier "w" |
| 22 | // CHECK: fix-it:{{.*}}:{19:26-19:31}:"%w[s0]" |
| 23 | |
| 24 | return byte; |
| 25 | } |
| 26 | |
| 27 | #define PERCENT "%" |
| 28 | |
| 29 | uint8_t constraint_r_symbolic_macro(uint8_t *addr) { |
| 30 | uint8_t byte; |
| 31 | |
| 32 | __asm__ volatile("ldrb "PERCENT"[s0], [%[s1]]" : [s0] "=r" (byte) : [s1] "r" (addr) : "memory"); |
| 33 | // CHECK: warning: value size does not match register size specified by the constraint and modifier |
| 34 | // CHECK: note: use constraint modifier "w" |
| 35 | // CHECK-NOT: fix-it |
| 36 | |
| 37 | return byte; |
| 38 | } |
Akira Hatanaka | 96a3601 | 2015-02-04 00:27:13 +0000 | [diff] [blame] | 39 | |
| 40 | // CHECK: warning: value size does not match register size specified by the constraint and modifier |
| 41 | // CHECK: asm ("%w0 %w1 %2" : "+r" (one) : "r" (wide_two)); |
| 42 | // CHECK: note: use constraint modifier "w" |
| 43 | // CHECK: fix-it:{{.*}}:{47:17-47:19}:"%w2" |
| 44 | |
| 45 | void read_write_modifier0(int one, int two) { |
| 46 | long wide_two = two; |
| 47 | asm ("%w0 %w1 %2" : "+r" (one) : "r" (wide_two)); |
| 48 | } |
| 49 | |
| 50 | // CHECK-NOT: warning: |
| 51 | void read_write_modifier1(int one, int two) { |
| 52 | long wide_two = two; |
| 53 | asm ("%w0 %1" : "+r" (one), "+r" (wide_two)); |
| 54 | } |