Edward O'Callaghan | 9b0cffe | 2009-10-27 03:47:36 +0000 | [diff] [blame^] | 1 | // RUN: clang-cc -x assembler-with-cpp -fdollars-in-identifiers=0 -E %s > %t | FileCheck -strict-whitespace -check-prefix=CHECK-Identifiers-False %s && |
Daniel Dunbar | 5bea06a | 2008-12-01 19:23:47 +0000 | [diff] [blame] | 2 | |
| 3 | #ifndef __ASSEMBLER__ |
| 4 | #error "__ASSEMBLER__ not defined" |
| 5 | #endif |
Chris Lattner | e966d9a | 2009-03-20 16:28:22 +0000 | [diff] [blame] | 6 | |
| 7 | |
| 8 | // Invalid token pasting is ok. |
Chris Lattner | e966d9a | 2009-03-20 16:28:22 +0000 | [diff] [blame] | 9 | #define A X ## . |
| 10 | 1: A |
Edward O'Callaghan | 9b0cffe | 2009-10-27 03:47:36 +0000 | [diff] [blame^] | 11 | // CHECK-Identifiers-False: 1: X . |
Chris Lattner | e966d9a | 2009-03-20 16:28:22 +0000 | [diff] [blame] | 12 | |
| 13 | // Line markers are not linemarkers in .S files, they are passed through. |
Chris Lattner | e966d9a | 2009-03-20 16:28:22 +0000 | [diff] [blame] | 14 | # 321 |
Edward O'Callaghan | 9b0cffe | 2009-10-27 03:47:36 +0000 | [diff] [blame^] | 15 | // CHECK-Identifiers-False: # 321 |
Chris Lattner | e966d9a | 2009-03-20 16:28:22 +0000 | [diff] [blame] | 16 | |
| 17 | // Unknown directives are passed through. |
Chris Lattner | e966d9a | 2009-03-20 16:28:22 +0000 | [diff] [blame] | 18 | # B C |
Edward O'Callaghan | 9b0cffe | 2009-10-27 03:47:36 +0000 | [diff] [blame^] | 19 | // CHECK-Identifiers-False: # B C |
Chris Lattner | e966d9a | 2009-03-20 16:28:22 +0000 | [diff] [blame] | 20 | |
| 21 | // Unknown directives are expanded. |
Chris Lattner | e966d9a | 2009-03-20 16:28:22 +0000 | [diff] [blame] | 22 | #define D(x) BAR ## x |
| 23 | # D(42) |
Edward O'Callaghan | 9b0cffe | 2009-10-27 03:47:36 +0000 | [diff] [blame^] | 24 | // CHECK-Identifiers-False: # BAR42 |
Chris Lattner | e966d9a | 2009-03-20 16:28:22 +0000 | [diff] [blame] | 25 | |
| 26 | // Unmatched quotes are permitted. |
Chris Lattner | e966d9a | 2009-03-20 16:28:22 +0000 | [diff] [blame] | 27 | 2: ' |
| 28 | 3: " |
Edward O'Callaghan | 9b0cffe | 2009-10-27 03:47:36 +0000 | [diff] [blame^] | 29 | // CHECK-Identifiers-False: 2: ' |
| 30 | // CHECK-Identifiers-False: 3: " |
Chris Lattner | e966d9a | 2009-03-20 16:28:22 +0000 | [diff] [blame] | 31 | |
Daniel Dunbar | c25d805 | 2009-05-22 21:35:34 +0000 | [diff] [blame] | 32 | // (balance quotes to keep editors happy): "' |
| 33 | |
Chris Lattner | e966d9a | 2009-03-20 16:28:22 +0000 | [diff] [blame] | 34 | // Empty char literals are ok. |
Chris Lattner | e966d9a | 2009-03-20 16:28:22 +0000 | [diff] [blame] | 35 | 4: '' |
Edward O'Callaghan | 9b0cffe | 2009-10-27 03:47:36 +0000 | [diff] [blame^] | 36 | // CHECK-Identifiers-False: 4: '' |
Chris Lattner | e966d9a | 2009-03-20 16:28:22 +0000 | [diff] [blame] | 37 | |
Chris Lattner | f1538de | 2009-03-23 17:32:45 +0000 | [diff] [blame] | 38 | |
| 39 | // Portions of invalid pasting should still expand as macros. |
| 40 | // rdar://6709206 |
Chris Lattner | f1538de | 2009-03-23 17:32:45 +0000 | [diff] [blame] | 41 | #define M4 expanded |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 42 | #define M5() M4 ## ( |
Chris Lattner | f1538de | 2009-03-23 17:32:45 +0000 | [diff] [blame] | 43 | |
| 44 | 5: M5() |
Edward O'Callaghan | 9b0cffe | 2009-10-27 03:47:36 +0000 | [diff] [blame^] | 45 | // CHECK-Identifiers-False: 5: expanded ( |
Chris Lattner | f1538de | 2009-03-23 17:32:45 +0000 | [diff] [blame] | 46 | |
Chris Lattner | f5db8f8 | 2009-04-19 07:00:02 +0000 | [diff] [blame] | 47 | // rdar://6804322 |
Chris Lattner | f5db8f8 | 2009-04-19 07:00:02 +0000 | [diff] [blame] | 48 | #define FOO(name) name ## $foo |
| 49 | 6: FOO(blarg) |
Edward O'Callaghan | 9b0cffe | 2009-10-27 03:47:36 +0000 | [diff] [blame^] | 50 | // CHECK-Identifiers-False: 6: blarg $foo |
Chris Lattner | f5db8f8 | 2009-04-19 07:00:02 +0000 | [diff] [blame] | 51 | |
Edward O'Callaghan | 9b0cffe | 2009-10-27 03:47:36 +0000 | [diff] [blame^] | 52 | // RUN: clang-cc -x assembler-with-cpp -fdollars-in-identifiers=1 -E %s > %t | FileCheck -check-prefix=CHECK-Identifiers-True -strict-whitespace %s && |
Chris Lattner | f5db8f8 | 2009-04-19 07:00:02 +0000 | [diff] [blame] | 53 | #define FOO(name) name ## $foo |
| 54 | 7: FOO(blarg) |
Edward O'Callaghan | 9b0cffe | 2009-10-27 03:47:36 +0000 | [diff] [blame^] | 55 | // CHECK-Identifiers-True: 7: blarg$foo |
Chris Lattner | f1538de | 2009-03-23 17:32:45 +0000 | [diff] [blame] | 56 | |
Daniel Dunbar | c25d805 | 2009-05-22 21:35:34 +0000 | [diff] [blame] | 57 | // |
| 58 | #define T6() T6 #nostring |
| 59 | #define T7(x) T7 #x |
Chris Lattner | 3240469 | 2009-05-25 17:16:10 +0000 | [diff] [blame] | 60 | 8: T6() |
| 61 | 9: T7(foo) |
Edward O'Callaghan | 9b0cffe | 2009-10-27 03:47:36 +0000 | [diff] [blame^] | 62 | // CHECK-Identifiers-True: 8: T6 #nostring |
| 63 | // CHECK-Identifiers-True: 9: T7 "foo" |
Daniel Dunbar | c25d805 | 2009-05-22 21:35:34 +0000 | [diff] [blame] | 64 | |
Eli Friedman | 4c3ba6c | 2009-05-24 19:25:46 +0000 | [diff] [blame] | 65 | // Concatenation with period doesn't leave a space |
Eli Friedman | 4c3ba6c | 2009-05-24 19:25:46 +0000 | [diff] [blame] | 66 | #define T8(A,B) A ## B |
Chris Lattner | 3240469 | 2009-05-25 17:16:10 +0000 | [diff] [blame] | 67 | 10: T8(.,T8) |
Edward O'Callaghan | 9b0cffe | 2009-10-27 03:47:36 +0000 | [diff] [blame^] | 68 | // CHECK-Identifiers-True: 10: .T8 |
Chris Lattner | 3240469 | 2009-05-25 17:16:10 +0000 | [diff] [blame] | 69 | |
| 70 | // This should not crash. |
Chris Lattner | 3240469 | 2009-05-25 17:16:10 +0000 | [diff] [blame] | 71 | #define T11(a) #0 |
| 72 | 11: T11(b) |
Edward O'Callaghan | 9b0cffe | 2009-10-27 03:47:36 +0000 | [diff] [blame^] | 73 | // CHECK-Identifiers-True: 11: #0 |
Eli Friedman | 4c3ba6c | 2009-05-24 19:25:46 +0000 | [diff] [blame] | 74 | |
Chris Lattner | e966d9a | 2009-03-20 16:28:22 +0000 | [diff] [blame] | 75 | // RUN: true |