From 1984eb9a1522ad56e1310643a85f66b2b3424c91 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Tue, 22 Jun 2010 23:47:37 +0000 Subject: [PATCH] String literals enclosed in parentheses are still string literals. Fixes PR7488. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106607 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaExprCXX.cpp | 2 +- test/SemaCXX/overload-call.cpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp index 0e61f1d23a..3220494cbc 100644 --- a/lib/Sema/SemaExprCXX.cpp +++ b/lib/Sema/SemaExprCXX.cpp @@ -1540,7 +1540,7 @@ Sema::IsStringLiteralToNonConstPointerConversion(Expr *From, QualType ToType) { // be converted to an rvalue of type "pointer to char"; a wide // string literal can be converted to an rvalue of type "pointer // to wchar_t" (C++ 4.2p2). - if (StringLiteral *StrLit = dyn_cast(From)) + if (StringLiteral *StrLit = dyn_cast(From->IgnoreParens())) if (const PointerType *ToPtrType = ToType->getAs()) if (const BuiltinType *ToPointeeType = ToPtrType->getPointeeType()->getAs()) { diff --git a/test/SemaCXX/overload-call.cpp b/test/SemaCXX/overload-call.cpp index 9df5bc9f0c..37974ef929 100644 --- a/test/SemaCXX/overload-call.cpp +++ b/test/SemaCXX/overload-call.cpp @@ -54,6 +54,7 @@ double* k(bool); void test_k() { int* ip1 = k("foo"); // expected-warning{{conversion from string literal to 'char *' is deprecated}} + int* ip2 = k(("foo")); // expected-warning{{conversion from string literal to 'char *' is deprecated}} double* dp1 = k(L"foo"); } -- 2.40.0