Daniel Dunbar | a572887 | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 %s -fsyntax-only -verify -fms-extensions |
Chris Lattner | 636c5ef | 2009-01-16 08:21:25 +0000 | [diff] [blame] | 2 | |
| 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}} |
Andy Gibbs | 97f8461 | 2012-11-17 19:16:52 +0000 | [diff] [blame] | 14 | #pragma comment(compiler,) // expected-error {{expected string literal in pragma comment}} |
Chris Lattner | 636c5ef | 2009-01-16 08:21:25 +0000 | [diff] [blame] | 15 | #define foo compiler |
Chris Lattner | c7d945d | 2009-01-16 19:25:54 +0000 | [diff] [blame] | 16 | #pragma comment(foo) // macro expand kind. |
Chris Lattner | 636c5ef | 2009-01-16 08:21:25 +0000 | [diff] [blame] | 17 | #pragma comment(foo) x // expected-error {{pragma comment requires}} |
| 18 | |
Chris Lattner | c7d945d | 2009-01-16 19:25:54 +0000 | [diff] [blame] | 19 | #pragma comment(user, "foo\abar\nbaz\tsome thing") |
| 20 | |
John McCall | 1ef8a2e | 2010-08-28 22:34:47 +0000 | [diff] [blame] | 21 | |
| 22 | // __pragma |
| 23 | |
| 24 | __pragma(comment(linker," bar=" BAR)) |
| 25 | |
| 26 | #define MACRO_WITH__PRAGMA { \ |
| 27 | __pragma(warning(push)); \ |
| 28 | __pragma(warning(disable: 10000)); \ |
Matt Beaumont-Gay | 87b73ba | 2013-01-17 02:06:08 +0000 | [diff] [blame] | 29 | 1 + (2 > 3) ? 4 : 5; \ |
John McCall | 1ef8a2e | 2010-08-28 22:34:47 +0000 | [diff] [blame] | 30 | __pragma(warning(pop)); \ |
| 31 | } |
| 32 | |
| 33 | void f() |
| 34 | { |
| 35 | __pragma() |
| 36 | |
| 37 | // If we ever actually *support* __pragma(warning(disable: x)), |
| 38 | // this warning should go away. |
Matt Beaumont-Gay | 87b73ba | 2013-01-17 02:06:08 +0000 | [diff] [blame] | 39 | MACRO_WITH__PRAGMA // expected-warning {{lower precedence}} \ |
| 40 | // expected-note 2 {{place parentheses}} |
John McCall | 1ef8a2e | 2010-08-28 22:34:47 +0000 | [diff] [blame] | 41 | } |
Aaron Ballman | 4c55c54 | 2012-03-02 22:51:54 +0000 | [diff] [blame] | 42 | |
| 43 | |
| 44 | // This should include macro_arg_directive even though the include |
| 45 | // is looking for test.h This allows us to assign to "n" |
| 46 | #pragma include_alias("test.h", "macro_arg_directive.h" ) |
| 47 | #include "test.h" |
| 48 | void test( void ) { |
| 49 | n = 12; |
| 50 | } |
| 51 | |
| 52 | #pragma include_alias(<bar.h>, "bar.h") // expected-warning {{angle-bracketed include <bar.h> cannot be aliased to double-quoted include "bar.h"}} |
| 53 | #pragma include_alias("foo.h", <bar.h>) // expected-warning {{double-quoted include "foo.h" cannot be aliased to angle-bracketed include <bar.h>}} |
| 54 | #pragma include_alias("test.h") // expected-warning {{pragma include_alias expected ','}} |
| 55 | |
| 56 | // Make sure that the names match exactly for a replacement, including path information. If |
| 57 | // this were to fail, we would get a file not found error |
| 58 | #pragma include_alias(".\pp-record.h", "does_not_exist.h") |
| 59 | #include "pp-record.h" |
| 60 | |
| 61 | #pragma include_alias(12) // expected-warning {{pragma include_alias expected include filename}} |
| 62 | |
| 63 | // It's expected that we can map "bar" and <bar> separately |
| 64 | #define test |
| 65 | // We can't actually look up stdio.h because we're using cc1 without header paths, but this will ensure |
| 66 | // that we get the right bar.h, because the "bar.h" will undef test for us, where <bar.h> won't |
| 67 | #pragma include_alias(<bar.h>, <stdio.h>) |
| 68 | #pragma include_alias("bar.h", "pr2086.h") // This should #undef test |
| 69 | |
| 70 | #include "bar.h" |
| 71 | #if defined(test) |
| 72 | // This should not warn because test should not be defined |
| 73 | #pragma include_alias("test.h") |
| 74 | #endif |
| 75 | |
| 76 | // Test to make sure there are no use-after-free problems |
| 77 | #define B "pp-record.h" |
| 78 | #pragma include_alias("quux.h", B) |
| 79 | void g() {} |
| 80 | #include "quux.h" |
| 81 | |
| 82 | // Make sure that empty includes don't work |
| 83 | #pragma include_alias("", "foo.h") // expected-error {{empty filename}} |
| 84 | #pragma include_alias(<foo.h>, <>) // expected-error {{empty filename}} |