blob: f7706ca676ce8b5b2ea8dcf7f71c289199c3de4f [file] [log] [blame]
Chris Lattnerf5db8f82009-04-19 07:00:02 +00001// RUN: clang-cc -x assembler-with-cpp -fdollars-in-identifiers=0 -E %s > %t &&
Daniel Dunbar5bea06a2008-12-01 19:23:47 +00002
3#ifndef __ASSEMBLER__
4#error "__ASSEMBLER__ not defined"
5#endif
Chris Lattnere966d9a2009-03-20 16:28:22 +00006
7
8// Invalid token pasting is ok.
9// RUN: grep '1: X .' %t &&
10#define A X ## .
111: A
12
13// Line markers are not linemarkers in .S files, they are passed through.
14// RUN: grep '# 321' %t &&
15# 321
16
17// Unknown directives are passed through.
18// RUN: grep '# B C' %t &&
19# B C
20
21// Unknown directives are expanded.
22// RUN: grep '# BAR42' %t &&
23#define D(x) BAR ## x
24# D(42)
25
26// Unmatched quotes are permitted.
27// RUN: grep "2: '" %t &&
28// RUN: grep '3: "' %t &&
292: '
303: "
31
Daniel Dunbarc25d8052009-05-22 21:35:34 +000032// (balance quotes to keep editors happy): "'
33
Chris Lattnere966d9a2009-03-20 16:28:22 +000034// Empty char literals are ok.
35// RUN: grep "4: ''" %t &&
364: ''
37
Chris Lattnerf1538de2009-03-23 17:32:45 +000038
39// Portions of invalid pasting should still expand as macros.
40// rdar://6709206
41// RUN: grep "5: expanded (" %t &&
42#define M4 expanded
Mike Stump1eb44332009-09-09 15:08:12 +000043#define M5() M4 ## (
Chris Lattnerf1538de2009-03-23 17:32:45 +000044
455: M5()
46
Chris Lattnerf5db8f82009-04-19 07:00:02 +000047// rdar://6804322
48// RUN: grep -F "6: blarg $foo" %t &&
49#define FOO(name) name ## $foo
506: FOO(blarg)
51
52// RUN: clang-cc -x assembler-with-cpp -fdollars-in-identifiers=1 -E %s > %t &&
53// RUN: grep -F "7: blarg$foo" %t &&
54#define FOO(name) name ## $foo
557: FOO(blarg)
Chris Lattnerf1538de2009-03-23 17:32:45 +000056
57
Daniel Dunbarc25d8052009-05-22 21:35:34 +000058//
59#define T6() T6 #nostring
60#define T7(x) T7 #x
Chris Lattner32404692009-05-25 17:16:10 +0000618: T6()
629: T7(foo)
63// RUN: grep '8: T6 #nostring' %t &&
64// RUN: grep '9: T7 "foo"' %t &&
Daniel Dunbarc25d8052009-05-22 21:35:34 +000065
Eli Friedman4c3ba6c2009-05-24 19:25:46 +000066// Concatenation with period doesn't leave a space
Chris Lattner32404692009-05-25 17:16:10 +000067// RUN: grep -F '10: .T8' %t &&
Eli Friedman4c3ba6c2009-05-24 19:25:46 +000068#define T8(A,B) A ## B
Chris Lattner32404692009-05-25 17:16:10 +00006910: T8(.,T8)
70
71
72// This should not crash.
73// RUN: grep '11: #0' %t &&
74#define T11(a) #0
7511: T11(b)
Eli Friedman4c3ba6c2009-05-24 19:25:46 +000076
Chris Lattnere966d9a2009-03-20 16:28:22 +000077// RUN: true