1 // RUN: %clang_cc1 -x assembler-with-cpp -E %s -o - | FileCheck -strict-whitespace -check-prefix=CHECK-Identifiers-False %s
2 
3 #ifndef __ASSEMBLER__
4 #error "__ASSEMBLER__ not defined"
5 #endif
6 
7 
8 // Invalid token pasting is ok.
9 #define A X ## .
10 1: A
11 // CHECK-Identifiers-False: 1: X .
12 
13 // Line markers are not linemarkers in .S files, they are passed through.
14 # 321
15 // CHECK-Identifiers-False: # 321
16 
17 // Unknown directives are passed through.
18 # B C
19 // CHECK-Identifiers-False: # B C
20 
21 // Unknown directives are expanded.
22 #define D(x) BAR ## x
23 # D(42)
24 // CHECK-Identifiers-False: # BAR42
25 
26 // Unmatched quotes are permitted.
27 2: '
28 3: "
29 // CHECK-Identifiers-False: 2: '
30 // CHECK-Identifiers-False: 3: "
31 
32 // (balance quotes to keep editors happy): "'
33 
34 // Empty char literals are ok.
35 4: ''
36 // CHECK-Identifiers-False: 4: ''
37 
38 
39 // Portions of invalid pasting should still expand as macros.
40 // rdar://6709206
41 #define M4 expanded
42 #define M5() M4 ## (
43 
44 5: M5()
45 // CHECK-Identifiers-False: 5: expanded (
46 
47 // rdar://6804322
48 #define FOO(name)  name ## $foo
49 6: FOO(blarg)
50 // CHECK-Identifiers-False: 6: blarg $foo
51 
52 // RUN: %clang_cc1 -x assembler-with-cpp -fdollars-in-identifiers -E %s -o - | FileCheck -check-prefix=CHECK-Identifiers-True -strict-whitespace %s
53 #define FOO(name)  name ## $foo
54 7: FOO(blarg)
55 // CHECK-Identifiers-True: 7: blarg$foo
56 
57 //
58 #define T6() T6 #nostring
59 #define T7(x) T7 #x
60 8: T6()
61 9: T7(foo)
62 // CHECK-Identifiers-True: 8: T6 #nostring
63 // CHECK-Identifiers-True: 9: T7 "foo"
64 
65 // Concatenation with period doesn't leave a space
66 #define T8(A,B) A ## B
67 10: T8(.,T8)
68 // CHECK-Identifiers-True: 10: .T8
69 
70 // This should not crash.
71 #define T11(a) #0
72 11: T11(b)
73 // CHECK-Identifiers-True: 11: #0
74 
75 // Universal character names can specify basic ascii and control characters
76 12: \u0020\u0030\u0080\u0000
77 // CHECK-Identifiers-False: 12: \u0020\u0030\u0080\u0000
78 
79 // This should not crash
80 // rdar://8823139
81 # ##
82 // CHECK-Identifiers-False: # ##
83 
84 #define X(a) # # # 1
85 X(1)
86 // CHECK-Identifiers-False: # # # 1
87