blob: e461c707a9a5f85950e8fb155a1e35c005f45031 [file] [log] [blame]
Daniel Dunbara5728872009-12-15 20:14:24 +00001// RUN: %clang_cc1 %s -fsyntax-only -verify -fms-extensions
Chris Lattner636c5ef2009-01-16 08:21:25 +00002
3// rdar://6495941
4
5#define FOO 1
6#define BAR "2"
7
8#pragma comment(linker,"foo=" FOO) // expected-error {{pragma comment requires parenthesized identifier and optional string}}
9#pragma comment(linker," bar=" BAR)
10
11#pragma comment( user, "Compiled on " __DATE__ " at " __TIME__ )
12
13#pragma comment(foo) // expected-error {{unknown kind of pragma comment}}
14#pragma comment(compiler,) // expected-error {{pragma comment requires}}
15#define foo compiler
Chris Lattnerc7d945d2009-01-16 19:25:54 +000016#pragma comment(foo) // macro expand kind.
Chris Lattner636c5ef2009-01-16 08:21:25 +000017#pragma comment(foo) x // expected-error {{pragma comment requires}}
18
Chris Lattnerc7d945d2009-01-16 19:25:54 +000019#pragma comment(user, "foo\abar\nbaz\tsome thing")
20
John McCall1ef8a2e2010-08-28 22:34:47 +000021
22// __pragma
23
24__pragma(comment(linker," bar=" BAR))
25
26#define MACRO_WITH__PRAGMA { \
27 __pragma(warning(push)); \
28 __pragma(warning(disable: 10000)); \
29 2+2; \
30 __pragma(warning(pop)); \
31}
32
33void f()
34{
35 __pragma()
36
37 // If we ever actually *support* __pragma(warning(disable: x)),
38 // this warning should go away.
Argyrios Kyrtzidis1b2ad2f2010-09-19 23:03:35 +000039 MACRO_WITH__PRAGMA // expected-warning {{expression result unused}}
John McCall1ef8a2e2010-08-28 22:34:47 +000040}
Aaron Ballman4c55c542012-03-02 22:51:54 +000041
42
43// This should include macro_arg_directive even though the include
44// is looking for test.h This allows us to assign to "n"
45#pragma include_alias("test.h", "macro_arg_directive.h" )
46#include "test.h"
47void test( void ) {
48 n = 12;
49}
50
51#pragma include_alias(<bar.h>, "bar.h") // expected-warning {{angle-bracketed include <bar.h> cannot be aliased to double-quoted include "bar.h"}}
52#pragma include_alias("foo.h", <bar.h>) // expected-warning {{double-quoted include "foo.h" cannot be aliased to angle-bracketed include <bar.h>}}
53#pragma include_alias("test.h") // expected-warning {{pragma include_alias expected ','}}
54
55// Make sure that the names match exactly for a replacement, including path information. If
56// this were to fail, we would get a file not found error
57#pragma include_alias(".\pp-record.h", "does_not_exist.h")
58#include "pp-record.h"
59
60#pragma include_alias(12) // expected-warning {{pragma include_alias expected include filename}}
61
62// It's expected that we can map "bar" and <bar> separately
63#define test
64// We can't actually look up stdio.h because we're using cc1 without header paths, but this will ensure
65// that we get the right bar.h, because the "bar.h" will undef test for us, where <bar.h> won't
66#pragma include_alias(<bar.h>, <stdio.h>)
67#pragma include_alias("bar.h", "pr2086.h") // This should #undef test
68
69#include "bar.h"
70#if defined(test)
71// This should not warn because test should not be defined
72#pragma include_alias("test.h")
73#endif
74
75// Test to make sure there are no use-after-free problems
76#define B "pp-record.h"
77#pragma include_alias("quux.h", B)
78void g() {}
79#include "quux.h"
80
81// Make sure that empty includes don't work
82#pragma include_alias("", "foo.h") // expected-error {{empty filename}}
83#pragma include_alias(<foo.h>, <>) // expected-error {{empty filename}}