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