]> granicus.if.org Git - clang/commitdiff
Warn for missing terminating " or ' instead of error for gcc compatibility. Fixed...
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Tue, 15 Feb 2011 23:45:31 +0000 (23:45 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Tue, 15 Feb 2011 23:45:31 +0000 (23:45 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125616 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/DiagnosticLexKinds.td
lib/Lex/Lexer.cpp
test/Lexer/rdar-8914293.c [new file with mode: 0644]

index 85573de02cfb5f778cf225ba1fed78bad398ff2b..813e2983ef7894abea7070d7164219a4c0540a4a 100644 (file)
@@ -45,8 +45,8 @@ def charize_microsoft_ext : Extension<"@# is a microsoft extension">;
 
 def ext_token_used : Extension<"extension used">;
 
-def err_unterminated_string : Error<"missing terminating '\"' character">;
-def err_unterminated_char : Error<"missing terminating ' character">;
+def warn_unterminated_string : Warning<"missing terminating '\"' character">;
+def warn_unterminated_char : Warning<"missing terminating ' character">;
 def err_empty_character : Error<"empty character constant">;
 def err_unterminated_block_comment : Error<"unterminated /* comment">;
 def err_invalid_character_to_charify : Error<
index fd5bb617a08f1d9d77040554bae6afbc64cb5c5c..b17198b219838dc66f8a505451b2c200575067fe 100644 (file)
@@ -1162,7 +1162,7 @@ void Lexer::LexStringLiteral(Token &Result, const char *CurPtr, bool Wide) {
       if (C == 0 && PP && PP->isCodeCompletionFile(FileLoc))
         PP->CodeCompleteNaturalLanguage();
       else if (!isLexingRawMode() && !Features.AsmPreprocessor)
-        Diag(BufferPtr, diag::err_unterminated_string);
+        Diag(BufferPtr, diag::warn_unterminated_string);
       FormTokenWithChars(Result, CurPtr-1, tok::unknown);
       return;
     }
@@ -1241,7 +1241,7 @@ void Lexer::LexCharConstant(Token &Result, const char *CurPtr) {
       if (C == 0 && PP && PP->isCodeCompletionFile(FileLoc))
         PP->CodeCompleteNaturalLanguage();
       else if (!isLexingRawMode() && !Features.AsmPreprocessor)
-        Diag(BufferPtr, diag::err_unterminated_char);
+        Diag(BufferPtr, diag::warn_unterminated_char);
       FormTokenWithChars(Result, CurPtr-1, tok::unknown);
       return;
     } else if (C == 0) {
diff --git a/test/Lexer/rdar-8914293.c b/test/Lexer/rdar-8914293.c
new file mode 100644 (file)
index 0000000..e39e4f1
--- /dev/null
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// rdar://8914293
+// We want be compatible with gcc and warn, not error.
+
+/* expected-warning {{missing terminating}} */ #define FOO "foo
+/* expected-warning {{missing terminating}} */ #define KOO 'k