]> granicus.if.org Git - clang/commitdiff
String literals enclosed in parentheses are still string
authorDouglas Gregor <dgregor@apple.com>
Tue, 22 Jun 2010 23:47:37 +0000 (23:47 +0000)
committerDouglas Gregor <dgregor@apple.com>
Tue, 22 Jun 2010 23:47:37 +0000 (23:47 +0000)
literals. Fixes PR7488.

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

lib/Sema/SemaExprCXX.cpp
test/SemaCXX/overload-call.cpp

index 0e61f1d23a8898750823670b034356200a659cfa..3220494cbc8162af21f0060c1ecf6df1cc447a36 100644 (file)
@@ -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<StringLiteral>(From))
+  if (StringLiteral *StrLit = dyn_cast<StringLiteral>(From->IgnoreParens()))
     if (const PointerType *ToPtrType = ToType->getAs<PointerType>())
       if (const BuiltinType *ToPointeeType
           = ToPtrType->getPointeeType()->getAs<BuiltinType>()) {
index 9df5bc9f0c74bd4286a63cddedc814c1431259ab..37974ef929e7a52ae33b7c58f90001614023f446 100644 (file)
@@ -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");
 }