xref: /minix3/external/bsd/llvm/dist/clang/test/Lexer/pragma-message.c (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc /* Test pragma message directive from
2*f4a2713aSLionel Sambuc    http://msdn.microsoft.com/en-us/library/x7dkzch2.aspx */
3*f4a2713aSLionel Sambuc 
4*f4a2713aSLionel Sambuc // message: Sends a string literal to the standard output without terminating
5*f4a2713aSLionel Sambuc // the compilation.
6*f4a2713aSLionel Sambuc // #pragma message(messagestring)
7*f4a2713aSLionel Sambuc // OR
8*f4a2713aSLionel Sambuc // #pragma message messagestring
9*f4a2713aSLionel Sambuc //
10*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -verify -Werror %s
11*f4a2713aSLionel Sambuc #define STRING2(x) #x
12*f4a2713aSLionel Sambuc #define STRING(x) STRING2(x)
13*f4a2713aSLionel Sambuc #pragma message(":O I'm a message! " STRING(__LINE__)) // expected-warning {{:O I'm a message! 13}}
14*f4a2713aSLionel Sambuc #pragma message ":O gcc accepts this! " STRING(__LINE__) // expected-warning {{:O gcc accepts this! 14}}
15*f4a2713aSLionel Sambuc 
16*f4a2713aSLionel Sambuc #pragma message(invalid) // expected-error {{expected string literal in pragma message}}
17*f4a2713aSLionel Sambuc 
18*f4a2713aSLionel Sambuc // GCC supports a similar pragma, #pragma GCC warning (which generates a warning
19*f4a2713aSLionel Sambuc // message) and #pragma GCC error (which generates an error message).
20*f4a2713aSLionel Sambuc 
21*f4a2713aSLionel Sambuc #pragma GCC warning(":O I'm a message! " STRING(__LINE__)) // expected-warning {{:O I'm a message! 21}}
22*f4a2713aSLionel Sambuc #pragma GCC warning ":O gcc accepts this! " STRING(__LINE__) // expected-warning {{:O gcc accepts this! 22}}
23*f4a2713aSLionel Sambuc 
24*f4a2713aSLionel Sambuc #pragma GCC error(":O I'm a message! " STRING(__LINE__)) // expected-error {{:O I'm a message! 24}}
25*f4a2713aSLionel Sambuc #pragma GCC error ":O gcc accepts this! " STRING(__LINE__) // expected-error {{:O gcc accepts this! 25}}
26*f4a2713aSLionel Sambuc 
27*f4a2713aSLionel Sambuc #define COMPILE_ERROR(x) _Pragma(STRING2(GCC error(x)))
28*f4a2713aSLionel Sambuc COMPILE_ERROR("Compile error at line " STRING(__LINE__) "!"); // expected-error {{Compile error at line 28!}}
29*f4a2713aSLionel Sambuc 
30*f4a2713aSLionel Sambuc #pragma message // expected-error {{pragma message requires parenthesized string}}
31*f4a2713aSLionel Sambuc #pragma GCC warning("" // expected-error {{pragma warning requires parenthesized string}}
32*f4a2713aSLionel Sambuc #pragma GCC error(1) // expected-error {{expected string literal in pragma error}}
33