1 // RUN: %clang_cc1 %s -fsyntax-only -verify -fms-extensions
2 // REQUIRES: non-ps4-sdk
3
4 // rdar://6495941
5
6 #define FOO 1
7 #define BAR "2"
8
9 #pragma comment(linker,"foo=" FOO) // expected-error {{pragma comment requires parenthesized identifier and optional string}}
10 #pragma comment(linker," bar=" BAR)
11
12 #pragma comment( user, "Compiled on " __DATE__ " at " __TIME__ )
13
14 #pragma comment(foo) // expected-error {{unknown kind of pragma comment}}
15 #pragma comment(compiler,) // expected-error {{expected string literal in pragma comment}}
16 #define foo compiler
17 #pragma comment(foo) // macro expand kind.
18 #pragma comment(foo) x // expected-error {{pragma comment requires}}
19
20 #pragma comment(user, "foo\abar\nbaz\tsome thing")
21
22 #pragma detect_mismatch("test", "1")
23 #pragma detect_mismatch() // expected-error {{expected string literal in pragma detect_mismatch}}
24 #pragma detect_mismatch("test") // expected-error {{pragma detect_mismatch is malformed; it requires two comma-separated string literals}}
25 #pragma detect_mismatch("test", 1) // expected-error {{expected string literal in pragma detect_mismatch}}
26 #pragma detect_mismatch("test", BAR)
27
28 // __pragma
29
30 __pragma(comment(linker," bar=" BAR))
31
32 #define MACRO_WITH__PRAGMA { \
33 __pragma(warning(push)); \
34 __pragma(warning(disable: 10000)); \
35 1 + (2 > 3) ? 4 : 5; \
36 __pragma(warning(pop)); \
37 }
38
f()39 void f()
40 {
41 __pragma()
42
43 // If we ever actually *support* __pragma(warning(disable: x)),
44 // this warning should go away.
45 MACRO_WITH__PRAGMA // expected-warning {{lower precedence}} \
46 // expected-note 2 {{place parentheses}}
47 }
48
49
50 // This should include macro_arg_directive even though the include
51 // is looking for test.h This allows us to assign to "n"
52 #pragma include_alias("test.h", "macro_arg_directive.h" )
53 #include "test.h"
test(void)54 void test( void ) {
55 n = 12;
56 }
57
58 #pragma include_alias(<bar.h>, "bar.h") // expected-warning {{angle-bracketed include <bar.h> cannot be aliased to double-quoted include "bar.h"}}
59 #pragma include_alias("foo.h", <bar.h>) // expected-warning {{double-quoted include "foo.h" cannot be aliased to angle-bracketed include <bar.h>}}
60 #pragma include_alias("test.h") // expected-warning {{pragma include_alias expected ','}}
61
62 // Make sure that the names match exactly for a replacement, including path information. If
63 // this were to fail, we would get a file not found error
64 #pragma include_alias(".\pp-record.h", "does_not_exist.h")
65 #include "pp-record.h"
66
67 #pragma include_alias(12) // expected-warning {{pragma include_alias expected include filename}}
68
69 // It's expected that we can map "bar" and <bar> separately
70 #define test
71 // We can't actually look up stdio.h because we're using cc1 without header paths, but this will ensure
72 // that we get the right bar.h, because the "bar.h" will undef test for us, where <bar.h> won't
73 #pragma include_alias(<bar.h>, <stdio.h>)
74 #pragma include_alias("bar.h", "pr2086.h") // This should #undef test
75
76 #include "bar.h"
77 #if defined(test)
78 // This should not warn because test should not be defined
79 #pragma include_alias("test.h")
80 #endif
81
82 // Test to make sure there are no use-after-free problems
83 #define B "pp-record.h"
84 #pragma include_alias("quux.h", B)
g()85 void g() {}
86 #include "quux.h"
87
88 // Make sure that empty includes don't work
89 #pragma include_alias("", "foo.h") // expected-error {{empty filename}}
90 #pragma include_alias(<foo.h>, <>) // expected-error {{empty filename}}
91
92 // Test that we ignore pragma warning.
93 #pragma warning(push)
94 #pragma warning(push, 1)
95 #pragma warning(disable : 4705)
96 #pragma warning(disable : 123 456 789 ; error : 321)
97 #pragma warning(once : 321)
98 #pragma warning(suppress : 321)
99 #pragma warning(default : 321)
100 #pragma warning(pop)
101
102 #pragma warning(push, 0)
103 // FIXME: We could probably support pushing warning level 0.
104 #pragma warning(pop)
105
106 #pragma warning // expected-warning {{expected '('}}
107 #pragma warning( // expected-warning {{expected 'push', 'pop', 'default', 'disable', 'error', 'once', 'suppress', 1, 2, 3, or 4}}
108 #pragma warning() // expected-warning {{expected 'push', 'pop', 'default', 'disable', 'error', 'once', 'suppress', 1, 2, 3, or 4}}
109 #pragma warning(push 4) // expected-warning {{expected ')'}}
110 #pragma warning(push // expected-warning {{expected ')'}}
111 #pragma warning(push, 5) // expected-warning {{requires a level between 0 and 4}}
112 #pragma warning(pop, 1) // expected-warning {{expected ')'}}
113 #pragma warning(push, 1) asdf // expected-warning {{extra tokens at end of #pragma warning directive}}
114 #pragma warning(disable 4705) // expected-warning {{expected ':'}}
115 #pragma warning(disable : 0) // expected-warning {{expected a warning number}}
116 #pragma warning(default 321) // expected-warning {{expected ':'}}
117 #pragma warning(asdf : 321) // expected-warning {{expected 'push', 'pop'}}
118 #pragma warning(push, -1) // expected-warning {{requires a level between 0 and 4}}
119