blob: dcc5336b91c1437b840bb31bc5367c5d775144d4 [file] [log] [blame]
Nico Weber446cf252015-12-29 23:06:17 +00001// RUN: %clang_cc1 -verify -fms-extensions -Wmicrosoft %s
Rafael Espindola925213b2013-07-04 16:16:58 +00002// RUN: not %clang_cc1 -P -E -fms-extensions %s | FileCheck -strict-whitespace %s
Chris Lattner52c00bd2010-07-17 16:24:30 +00003
Chris Lattner3b5054d2008-02-07 06:03:59 +00004// This horrible stuff should preprocess into (other than whitespace):
5// int foo;
6// int bar;
7// int baz;
8
9int foo;
10
Edward O'Callaghanf78edf52009-10-27 02:36:32 +000011// CHECK: int foo;
12
Chris Lattner3b5054d2008-02-07 06:03:59 +000013#define comment /##/ dead tokens live here
Nico Weber446cf252015-12-29 23:06:17 +000014// expected-warning@+1 {{pasting two '/' tokens}}
Chris Lattner3b5054d2008-02-07 06:03:59 +000015comment This is stupidity
16
17int bar;
18
Edward O'Callaghanf78edf52009-10-27 02:36:32 +000019// CHECK: int bar;
20
Chris Lattner3b5054d2008-02-07 06:03:59 +000021#define nested(x) int x comment cute little dead tokens...
22
Nico Weber446cf252015-12-29 23:06:17 +000023// expected-warning@+1 {{pasting two '/' tokens}}
Chris Lattner3b5054d2008-02-07 06:03:59 +000024nested(baz) rise of the dead tokens
25
26;
27
Edward O'Callaghanf78edf52009-10-27 02:36:32 +000028// CHECK: int baz
29// CHECK: ;
30
Chris Lattner52c00bd2010-07-17 16:24:30 +000031
32// rdar://8197149 - VC++ allows invalid token pastes: (##baz
33#define foo(x) abc(x)
34#define bar(y) foo(##baz(y))
Nico Weber446cf252015-12-29 23:06:17 +000035bar(q) // expected-warning {{type specifier missing}} expected-error {{invalid preprocessing token}} expected-error {{parameter list without types}}
Chris Lattner52c00bd2010-07-17 16:24:30 +000036
37// CHECK: abc(baz(q))
Will Wilsondb2588a2015-04-17 12:43:57 +000038
39
40#define str(x) #x
41#define collapse_spaces(a, b, c, d) str(a ## - ## b ## - ## c ## d)
Nico Weber446cf252015-12-29 23:06:17 +000042collapse_spaces(1a, b2, 3c, d4) // expected-error 4 {{invalid preprocessing token}} expected-error {{expected function body}}
Will Wilsondb2588a2015-04-17 12:43:57 +000043
44// CHECK: "1a-b2-3cd4"