String literals enclosed in parentheses are still string

literals. Fixes PR7488.

llvm-svn: 106607
This commit is contained in:
Douglas Gregor
2010-06-22 23:47:37 +00:00
parent 468574bd34
commit 689999da1f
2 changed files with 2 additions and 1 deletions

View 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>()) {

View 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");
}