]> granicus.if.org Git - clang/commitdiff
Dropped the parentheses for #pragma message and its kin in the -E output generator.
authorAndy Gibbs <andyg1001@hotmail.co.uk>
Thu, 18 Apr 2013 16:49:37 +0000 (16:49 +0000)
committerAndy Gibbs <andyg1001@hotmail.co.uk>
Thu, 18 Apr 2013 16:49:37 +0000 (16:49 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@179771 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Frontend/PrintPreprocessedOutput.cpp
test/Lexer/pragma-message2.c [new file with mode: 0644]
test/Lexer/pragma-operators.cpp

index 61f2b9e288420a976448225fc37714afa02dc197..6d7a1db7379e913acac7851f4df845a8d37c2bb4 100644 (file)
@@ -419,13 +419,13 @@ void PrintPPOutputPPCallbacks::PragmaMessage(SourceLocation Loc,
     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::PragmaMessage(SourceLocation Loc,
          << (char)('0'+ ((Char >> 0) & 7));
   }
   OS << '"';
-
-  OS << ')';
   setEmittedDirectiveOnThisLine();
 }
 
diff --git a/test/Lexer/pragma-message2.c b/test/Lexer/pragma-message2.c
new file mode 100644 (file)
index 0000000..4b40782
--- /dev/null
@@ -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]"
index 6a5a498a151ff0a653f13c2e775e2f68ef3a45d7..7402f9f8c4bb0d90688f3ef274cd777b41597062 100644 (file)
@@ -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;