2015-10-13 04:47:58 +08:00
|
|
|
// RUN: %clang_cc1 %s -fsyntax-only -verify -fms-extensions -Wunknown-pragmas
|
2015-05-25 19:21:20 +08:00
|
|
|
// RUN: not %clang_cc1 %s -fms-extensions -E | FileCheck %s
|
2015-03-26 04:16:29 +08:00
|
|
|
// REQUIRES: non-ps4-sdk
|
2009-01-16 16:21:25 +08:00
|
|
|
|
|
|
|
// rdar://6495941
|
|
|
|
|
|
|
|
#define FOO 1
|
|
|
|
#define BAR "2"
|
|
|
|
|
|
|
|
#pragma comment(linker,"foo=" FOO) // expected-error {{pragma comment requires parenthesized identifier and optional string}}
|
2015-05-25 19:21:20 +08:00
|
|
|
// CHECK: #pragma comment(linker,"foo=" 1)
|
2009-01-16 16:21:25 +08:00
|
|
|
#pragma comment(linker," bar=" BAR)
|
2015-05-25 19:21:20 +08:00
|
|
|
// CHECK: #pragma comment(linker," bar=" "2")
|
2009-01-16 16:21:25 +08:00
|
|
|
|
|
|
|
#pragma comment( user, "Compiled on " __DATE__ " at " __TIME__ )
|
2015-05-25 19:21:20 +08:00
|
|
|
// CHECK: {{#pragma comment\( user, \"Compiled on \".*\" at \".*\" \)}}
|
2009-01-16 16:21:25 +08:00
|
|
|
|
|
|
|
#pragma comment(foo) // expected-error {{unknown kind of pragma comment}}
|
2015-05-25 19:21:20 +08:00
|
|
|
// CHECK: #pragma comment(foo)
|
2012-11-18 03:16:52 +08:00
|
|
|
#pragma comment(compiler,) // expected-error {{expected string literal in pragma comment}}
|
2015-05-25 19:21:20 +08:00
|
|
|
// CHECK: #pragma comment(compiler,)
|
2009-01-16 16:21:25 +08:00
|
|
|
#define foo compiler
|
2009-01-17 03:25:54 +08:00
|
|
|
#pragma comment(foo) // macro expand kind.
|
2015-05-25 19:21:20 +08:00
|
|
|
// CHECK: #pragma comment(compiler)
|
2009-01-16 16:21:25 +08:00
|
|
|
#pragma comment(foo) x // expected-error {{pragma comment requires}}
|
2015-05-25 19:21:20 +08:00
|
|
|
// CHECK: #pragma comment(compiler) x
|
2009-01-16 16:21:25 +08:00
|
|
|
|
2009-01-17 03:25:54 +08:00
|
|
|
#pragma comment(user, "foo\abar\nbaz\tsome thing")
|
2015-05-25 19:21:20 +08:00
|
|
|
// CHECK: #pragma comment(user, "foo\abar\nbaz\tsome thing")
|
2009-01-17 03:25:54 +08:00
|
|
|
|
2013-06-04 10:07:14 +08:00
|
|
|
#pragma detect_mismatch("test", "1")
|
2015-05-25 19:21:20 +08:00
|
|
|
// CHECK: #pragma detect_mismatch("test", "1")
|
2013-06-04 10:07:14 +08:00
|
|
|
#pragma detect_mismatch() // expected-error {{expected string literal in pragma detect_mismatch}}
|
2015-05-25 19:21:20 +08:00
|
|
|
// CHECK: #pragma detect_mismatch()
|
2013-06-04 10:07:14 +08:00
|
|
|
#pragma detect_mismatch("test") // expected-error {{pragma detect_mismatch is malformed; it requires two comma-separated string literals}}
|
2015-05-25 19:21:20 +08:00
|
|
|
// CHECK: #pragma detect_mismatch("test")
|
2013-06-04 10:07:14 +08:00
|
|
|
#pragma detect_mismatch("test", 1) // expected-error {{expected string literal in pragma detect_mismatch}}
|
2015-05-25 19:21:20 +08:00
|
|
|
// CHECK: #pragma detect_mismatch("test", 1)
|
2013-06-04 10:07:14 +08:00
|
|
|
#pragma detect_mismatch("test", BAR)
|
2015-05-25 19:21:20 +08:00
|
|
|
// CHECK: #pragma detect_mismatch("test", "2")
|
2010-08-29 06:34:47 +08:00
|
|
|
|
|
|
|
// __pragma
|
|
|
|
|
2015-05-25 19:21:20 +08:00
|
|
|
__pragma(comment(linker," bar=" BAR))
|
|
|
|
// CHECK: #pragma comment(linker," bar=" "2")
|
2010-08-29 06:34:47 +08:00
|
|
|
|
|
|
|
#define MACRO_WITH__PRAGMA { \
|
|
|
|
__pragma(warning(push)); \
|
|
|
|
__pragma(warning(disable: 10000)); \
|
2013-01-17 10:06:08 +08:00
|
|
|
1 + (2 > 3) ? 4 : 5; \
|
2010-08-29 06:34:47 +08:00
|
|
|
__pragma(warning(pop)); \
|
|
|
|
}
|
|
|
|
|
|
|
|
void f()
|
|
|
|
{
|
2015-10-13 04:47:58 +08:00
|
|
|
__pragma() // expected-warning{{unknown pragma ignored}}
|
2015-05-25 19:21:20 +08:00
|
|
|
// CHECK: #pragma
|
2010-08-29 06:34:47 +08:00
|
|
|
|
|
|
|
// If we ever actually *support* __pragma(warning(disable: x)),
|
|
|
|
// this warning should go away.
|
2013-01-17 10:06:08 +08:00
|
|
|
MACRO_WITH__PRAGMA // expected-warning {{lower precedence}} \
|
|
|
|
// expected-note 2 {{place parentheses}}
|
2015-05-25 19:21:20 +08:00
|
|
|
// CHECK: #pragma warning(push)
|
|
|
|
// CHECK: #pragma warning(disable: 10000)
|
|
|
|
// CHECK: ; 1 + (2 > 3) ? 4 : 5;
|
|
|
|
// CHECK: #pragma warning(pop)
|
2010-08-29 06:34:47 +08:00
|
|
|
}
|
2012-03-03 06:51:54 +08:00
|
|
|
|
|
|
|
|
|
|
|
// This should include macro_arg_directive even though the include
|
|
|
|
// is looking for test.h This allows us to assign to "n"
|
|
|
|
#pragma include_alias("test.h", "macro_arg_directive.h" )
|
|
|
|
#include "test.h"
|
|
|
|
void test( void ) {
|
|
|
|
n = 12;
|
|
|
|
}
|
|
|
|
|
|
|
|
#pragma include_alias(<bar.h>, "bar.h") // expected-warning {{angle-bracketed include <bar.h> cannot be aliased to double-quoted include "bar.h"}}
|
|
|
|
#pragma include_alias("foo.h", <bar.h>) // expected-warning {{double-quoted include "foo.h" cannot be aliased to angle-bracketed include <bar.h>}}
|
|
|
|
#pragma include_alias("test.h") // expected-warning {{pragma include_alias expected ','}}
|
|
|
|
|
|
|
|
// Make sure that the names match exactly for a replacement, including path information. If
|
|
|
|
// this were to fail, we would get a file not found error
|
|
|
|
#pragma include_alias(".\pp-record.h", "does_not_exist.h")
|
|
|
|
#include "pp-record.h"
|
|
|
|
|
|
|
|
#pragma include_alias(12) // expected-warning {{pragma include_alias expected include filename}}
|
|
|
|
|
|
|
|
// It's expected that we can map "bar" and <bar> separately
|
|
|
|
#define test
|
|
|
|
// We can't actually look up stdio.h because we're using cc1 without header paths, but this will ensure
|
|
|
|
// that we get the right bar.h, because the "bar.h" will undef test for us, where <bar.h> won't
|
|
|
|
#pragma include_alias(<bar.h>, <stdio.h>)
|
|
|
|
#pragma include_alias("bar.h", "pr2086.h") // This should #undef test
|
|
|
|
|
|
|
|
#include "bar.h"
|
|
|
|
#if defined(test)
|
|
|
|
// This should not warn because test should not be defined
|
|
|
|
#pragma include_alias("test.h")
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Test to make sure there are no use-after-free problems
|
|
|
|
#define B "pp-record.h"
|
|
|
|
#pragma include_alias("quux.h", B)
|
|
|
|
void g() {}
|
|
|
|
#include "quux.h"
|
|
|
|
|
|
|
|
// Make sure that empty includes don't work
|
|
|
|
#pragma include_alias("", "foo.h") // expected-error {{empty filename}}
|
|
|
|
#pragma include_alias(<foo.h>, <>) // expected-error {{empty filename}}
|
2013-09-14 06:00:30 +08:00
|
|
|
|
|
|
|
// Test that we ignore pragma warning.
|
|
|
|
#pragma warning(push)
|
2015-05-25 19:21:20 +08:00
|
|
|
// CHECK: #pragma warning(push)
|
2013-09-14 06:00:30 +08:00
|
|
|
#pragma warning(push, 1)
|
2015-05-25 19:21:20 +08:00
|
|
|
// CHECK: #pragma warning(push, 1)
|
2013-09-14 06:00:30 +08:00
|
|
|
#pragma warning(disable : 4705)
|
2015-05-25 19:21:20 +08:00
|
|
|
// CHECK: #pragma warning(disable: 4705)
|
2013-09-14 06:00:30 +08:00
|
|
|
#pragma warning(disable : 123 456 789 ; error : 321)
|
2015-05-25 19:21:20 +08:00
|
|
|
// CHECK: #pragma warning(disable: 123 456 789)
|
|
|
|
// CHECK: #pragma warning(error: 321)
|
2013-09-14 06:00:30 +08:00
|
|
|
#pragma warning(once : 321)
|
2015-05-25 19:21:20 +08:00
|
|
|
// CHECK: #pragma warning(once: 321)
|
2013-09-14 06:00:30 +08:00
|
|
|
#pragma warning(suppress : 321)
|
2015-05-25 19:21:20 +08:00
|
|
|
// CHECK: #pragma warning(suppress: 321)
|
2013-09-14 06:00:30 +08:00
|
|
|
#pragma warning(default : 321)
|
2015-05-25 19:21:20 +08:00
|
|
|
// CHECK: #pragma warning(default: 321)
|
2013-09-14 06:00:30 +08:00
|
|
|
#pragma warning(pop)
|
2015-05-25 19:21:20 +08:00
|
|
|
// CHECK: #pragma warning(pop)
|
|
|
|
#pragma warning(1: 123)
|
|
|
|
// CHECK: #pragma warning(1: 123)
|
|
|
|
#pragma warning(2: 234 567)
|
|
|
|
// CHECK: #pragma warning(2: 234 567)
|
|
|
|
#pragma warning(3: 123; 4: 678)
|
|
|
|
// CHECK: #pragma warning(3: 123)
|
|
|
|
// CHECK: #pragma warning(4: 678)
|
|
|
|
#pragma warning(5: 123) // expected-warning {{expected 'push', 'pop', 'default', 'disable', 'error', 'once', 'suppress', 1, 2, 3, or 4}}
|
2013-09-14 06:00:30 +08:00
|
|
|
|
2013-10-02 23:19:23 +08:00
|
|
|
#pragma warning(push, 0)
|
2015-05-25 19:21:20 +08:00
|
|
|
// CHECK: #pragma warning(push, 0)
|
2013-10-02 23:19:23 +08:00
|
|
|
// FIXME: We could probably support pushing warning level 0.
|
|
|
|
#pragma warning(pop)
|
2015-05-25 19:21:20 +08:00
|
|
|
// CHECK: #pragma warning(pop)
|
2013-10-02 23:19:23 +08:00
|
|
|
|
2013-09-14 06:00:30 +08:00
|
|
|
#pragma warning // expected-warning {{expected '('}}
|
|
|
|
#pragma warning( // expected-warning {{expected 'push', 'pop', 'default', 'disable', 'error', 'once', 'suppress', 1, 2, 3, or 4}}
|
|
|
|
#pragma warning() // expected-warning {{expected 'push', 'pop', 'default', 'disable', 'error', 'once', 'suppress', 1, 2, 3, or 4}}
|
|
|
|
#pragma warning(push 4) // expected-warning {{expected ')'}}
|
2015-05-25 19:21:20 +08:00
|
|
|
// CHECK: #pragma warning(push)
|
2013-09-14 06:00:30 +08:00
|
|
|
#pragma warning(push // expected-warning {{expected ')'}}
|
2015-05-25 19:21:20 +08:00
|
|
|
// CHECK: #pragma warning(push)
|
2013-10-02 23:19:23 +08:00
|
|
|
#pragma warning(push, 5) // expected-warning {{requires a level between 0 and 4}}
|
2013-09-14 06:00:30 +08:00
|
|
|
#pragma warning(pop, 1) // expected-warning {{expected ')'}}
|
2015-05-25 19:21:20 +08:00
|
|
|
// CHECK: #pragma warning(pop)
|
2013-09-14 06:00:30 +08:00
|
|
|
#pragma warning(push, 1) asdf // expected-warning {{extra tokens at end of #pragma warning directive}}
|
2015-05-25 19:21:20 +08:00
|
|
|
// CHECK: #pragma warning(push, 1)
|
2013-09-14 06:00:30 +08:00
|
|
|
#pragma warning(disable 4705) // expected-warning {{expected ':'}}
|
|
|
|
#pragma warning(disable : 0) // expected-warning {{expected a warning number}}
|
|
|
|
#pragma warning(default 321) // expected-warning {{expected ':'}}
|
|
|
|
#pragma warning(asdf : 321) // expected-warning {{expected 'push', 'pop'}}
|
2013-10-02 23:19:23 +08:00
|
|
|
#pragma warning(push, -1) // expected-warning {{requires a level between 0 and 4}}
|
2015-10-13 04:47:58 +08:00
|
|
|
|
|
|
|
// Test that runtime_checks is parsed but ignored.
|
|
|
|
#pragma runtime_checks("sc", restore) // no-warning
|