r179771 - Dropped the parentheses for #pragma message and its kin in the -E output generator.

Jordan Rose jordan_rose at apple.com
Thu Apr 18 11:10:16 PDT 2013


No, that's not correct either. Microsoft's #pragma message requires parens, while #pragma GCC (error|warning) apparently requires no parens. (GCC's #pragma message seems to be MS-inspired, as it has no GCC namespace and optionally allows parens.)

http://msdn.microsoft.com/en-us/library/x7dkzch2(v=vs.80).aspx
http://gcc.gnu.org/onlinedocs/cpp/Pragmas.html
http://gcc.gnu.org/onlinedocs/gcc/Diagnostic-Pragmas.html

I'm okay with not really striving for source fidelity here; since there's no #pragma GCC message, it's probably safe to just parenthesize message all the time.
Jordan


On Apr 18, 2013, at 9:49 , Andy Gibbs <andyg1001 at hotmail.co.uk> wrote:

> Author: andyg
> Date: Thu Apr 18 11:49:37 2013
> New Revision: 179771
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=179771&view=rev
> Log:
> Dropped the parentheses for #pragma message and its kin in the -E output generator.
> 
> This was a suggestion by Jordan Rose since the documented format for these pragmas is without the parentheses.  At the same time, I've increased test coverage too for the preprocessed output.
> 
> Added:
>    cfe/trunk/test/Lexer/pragma-message2.c
> Modified:
>    cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp
>    cfe/trunk/test/Lexer/pragma-operators.cpp
> 
> Modified: cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp?rev=179771&r1=179770&r2=179771&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp (original)
> +++ cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp Thu Apr 18 11:49:37 2013
> @@ -419,13 +419,13 @@ void PrintPPOutputPPCallbacks::PragmaMes
>     OS << Namespace << ' ';
>   switch (Kind) {
>     case PMK_Message:
> -      OS << "message(\"";
> +      OS << "message \"";
>       break;
>     case PMK_Warning:
> -      OS << "warning(\"";
> +      OS << "warning \"";
>       break;
>     case PMK_Error:
> -      OS << "error(\"";
> +      OS << "error \"";
>       break;
>   }
> 
> @@ -440,8 +440,6 @@ void PrintPPOutputPPCallbacks::PragmaMes
>          << (char)('0'+ ((Char >> 0) & 7));
>   }
>   OS << '"';
> -
> -  OS << ')';
>   setEmittedDirectiveOnThisLine();
> }
> 
> 
> Added: cfe/trunk/test/Lexer/pragma-message2.c
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/pragma-message2.c?rev=179771&view=auto
> ==============================================================================
> --- cfe/trunk/test/Lexer/pragma-message2.c (added)
> +++ cfe/trunk/test/Lexer/pragma-message2.c Thu Apr 18 11:49:37 2013
> @@ -0,0 +1,19 @@
> +// RUN: %clang_cc1 -E -Werror -verify %s 2>&1 | FileCheck %s
> +
> +#pragma message "\\test" // expected-warning {{\test}}
> +// CHECK: #pragma message "\134test"
> +
> +#pragma message("\\test") // expected-warning {{\test}}
> +// CHECK: #pragma message "\134test"
> +
> +#pragma GCC warning "\"" "te" "st" "\"" // expected-warning {{"test"}}
> +// CHECK: #pragma GCC warning "\042test\042"
> +
> +#pragma GCC warning("\"" "te" "st" "\"") // expected-warning {{"test"}}
> +// CHECK: #pragma GCC warning "\042test\042"
> +
> +#pragma GCC error "" "[	]" "" // expected-error {{[	]}}
> +// CHECK: #pragma GCC error "[\011]"
> +
> +#pragma GCC error("" "[	]" "") // expected-error {{[	]}}
> +// CHECK: #pragma GCC error "[\011]"
> 
> Modified: cfe/trunk/test/Lexer/pragma-operators.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/pragma-operators.cpp?rev=179771&r1=179770&r2=179771&view=diff
> ==============================================================================
> --- cfe/trunk/test/Lexer/pragma-operators.cpp (original)
> +++ cfe/trunk/test/Lexer/pragma-operators.cpp Thu Apr 18 11:49:37 2013
> @@ -32,6 +32,6 @@ B(foo)
> // CHECK: #pragma comment(lib, "libfoo")
> // CHECK: #pragma clang diagnostic ignored "-Wunused"
> // CHECK: #pragma clang diagnostic error "-Wunused"
> -// CHECK: #pragma message("\042Hello\042, world!")
> +// CHECK: #pragma message "\042Hello\042, world!"
> // CHECK: 0;
> int n = pragma_L pragma_u8 pragma_u pragma_U pragma_R pragma_UR pragma_hello 0;
> 
> 
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130418/f0e6c207/attachment.html>


More information about the cfe-commits mailing list