From db9e9e61f8311d8852bd15730f78e56f3ffa0508 Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Tue, 15 Mar 2011 21:18:52 +0000 Subject: [PATCH] Remove warning for null characters in CFString literals. Clang handles them just fine, and GCC 4.2 doesn't warn here either. We added this warning back in 2007 when we were comparing against GCC 4.0. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127704 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Basic/DiagnosticSemaKinds.td | 2 -- lib/Sema/SemaChecking.cpp | 6 ------ test/Sema/builtins.c | 2 +- test/SemaObjC/exprs.m | 4 ++-- 4 files changed, 3 insertions(+), 11 deletions(-) diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td index 5b58ae8ab9..c42a82b5f6 100644 --- a/include/clang/Basic/DiagnosticSemaKinds.td +++ b/include/clang/Basic/DiagnosticSemaKinds.td @@ -3607,8 +3607,6 @@ def err_block_returning_array_function : Error< // CFString checking def err_cfstring_literal_not_string_constant : Error< "CFString literal is not a string constant">; -def warn_cfstring_literal_contains_nul_character : Warning< - "CFString literal contains NUL character">; def warn_cfstring_truncated : Warning< "input conversion stopped due to an input byte that does not " "belong to the input codeset UTF-8">; diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp index 24cf23bf43..de5a796410 100644 --- a/lib/Sema/SemaChecking.cpp +++ b/lib/Sema/SemaChecking.cpp @@ -552,12 +552,6 @@ bool Sema::CheckObjCString(Expr *Arg) { return true; } - size_t NulPos = Literal->getString().find('\0'); - if (NulPos != llvm::StringRef::npos) { - Diag(getLocationOfStringLiteralByte(Literal, NulPos), - diag::warn_cfstring_literal_contains_nul_character) - << Arg->getSourceRange(); - } if (Literal->containsNonAsciiOrNull()) { llvm::StringRef String = Literal->getString(); unsigned NumBytes = String.size(); diff --git a/test/Sema/builtins.c b/test/Sema/builtins.c index 4072faa94b..64efefc7fd 100644 --- a/test/Sema/builtins.c +++ b/test/Sema/builtins.c @@ -27,7 +27,7 @@ int test6(float a, long double b) { void test7() { const void *X; X = CFSTR("\242"); // expected-warning {{input conversion stopped}} - X = CFSTR("\0"); // expected-warning {{ CFString literal contains NUL character }} + X = CFSTR("\0"); // no-warning X = CFSTR(242); // expected-error {{ CFString literal is not a string constant }} expected-warning {{incompatible integer to pointer conversion}} X = CFSTR("foo", "bar"); // expected-error {{too many arguments to function call}} } diff --git a/test/SemaObjC/exprs.m b/test/SemaObjC/exprs.m index 13c34e5650..d7c122356f 100644 --- a/test/SemaObjC/exprs.m +++ b/test/SemaObjC/exprs.m @@ -9,12 +9,12 @@ Class test1(Class X) { // rdar://6079877 void test2() { id str = @"foo" - "bar\0" // expected-warning {{literal contains NUL character}} + "bar\0" // no-warning @"baz" " blarg"; id str2 = @"foo" "bar" @"baz" - " b\0larg"; // expected-warning {{literal contains NUL character}} + " b\0larg"; // no-warning if (@encode(int) == "foo") { } // expected-warning {{result of comparison against @encode is unspecified}} -- 2.40.0