summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-02-28 18:30:25 +0000
committerDouglas Gregor <dgregor@apple.com>2010-02-28 18:30:25 +0000
commite489a7d3d397214a43d587d88378f3df642aba60 (patch)
treee6ffcf44f1d49a62fc36fc58c4c148f1f635f3bb /clang/lib/Sema
parentfd48afe412e6a07e248f528d2650abe7c25b714a (diff)
downloadbcm5719-llvm-e489a7d3d397214a43d587d88378f3df642aba60.tar.gz
bcm5719-llvm-e489a7d3d397214a43d587d88378f3df642aba60.zip
Warn about the deprecated string literal -> char* conversion. Fixes PR6428.
llvm-svn: 97404
Diffstat (limited to 'clang/lib/Sema')
-rw-r--r--clang/lib/Sema/SemaExprCXX.cpp5
-rw-r--r--clang/lib/Sema/SemaOverload.cpp10
-rw-r--r--clang/lib/Sema/SemaOverload.h2
3 files changed, 11 insertions, 6 deletions
diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index daa4b5a98e4..23d52adf91a 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -1774,6 +1774,11 @@ Sema::PerformImplicitConversion(Expr *&From, QualType ToType,
ImpCastExprToType(From, ToType.getNonReferenceType(),
CastExpr::CK_NoOp,
ToType->isLValueReferenceType());
+
+ if (SCS.DeprecatedStringLiteralToCharPtr)
+ Diag(From->getLocStart(), diag::warn_deprecated_string_literal_conversion)
+ << ToType.getNonReferenceType();
+
break;
default:
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index 784663108b6..ed0d137d806 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -118,7 +118,7 @@ void StandardConversionSequence::setAsIdentityConversion() {
First = ICK_Identity;
Second = ICK_Identity;
Third = ICK_Identity;
- Deprecated = false;
+ DeprecatedStringLiteralToCharPtr = false;
ReferenceBinding = false;
DirectBinding = false;
RRefBinding = false;
@@ -549,7 +549,7 @@ Sema::IsStandardConversion(Expr* From, QualType ToType,
// Standard conversions (C++ [conv])
SCS.setAsIdentityConversion();
- SCS.Deprecated = false;
+ SCS.DeprecatedStringLiteralToCharPtr = false;
SCS.IncompatibleObjC = false;
SCS.setFromType(FromType);
SCS.CopyConstructor = 0;
@@ -592,7 +592,7 @@ Sema::IsStandardConversion(Expr* From, QualType ToType,
if (IsStringLiteralToNonConstPointerConversion(From, ToType)) {
// This conversion is deprecated. (C++ D.4).
- SCS.Deprecated = true;
+ SCS.DeprecatedStringLiteralToCharPtr = true;
// For the purpose of ranking in overload resolution
// (13.3.3.1.1), this conversion is considered an
@@ -1993,7 +1993,7 @@ Sema::CompareQualificationConversions(const StandardConversionSequence& SCS1,
// the deprecated string literal array to pointer conversion.
switch (Result) {
case ImplicitConversionSequence::Better:
- if (SCS1.Deprecated)
+ if (SCS1.DeprecatedStringLiteralToCharPtr)
Result = ImplicitConversionSequence::Indistinguishable;
break;
@@ -2001,7 +2001,7 @@ Sema::CompareQualificationConversions(const StandardConversionSequence& SCS1,
break;
case ImplicitConversionSequence::Worse:
- if (SCS2.Deprecated)
+ if (SCS2.DeprecatedStringLiteralToCharPtr)
Result = ImplicitConversionSequence::Indistinguishable;
break;
}
diff --git a/clang/lib/Sema/SemaOverload.h b/clang/lib/Sema/SemaOverload.h
index 62b096f703a..58e416c87e5 100644
--- a/clang/lib/Sema/SemaOverload.h
+++ b/clang/lib/Sema/SemaOverload.h
@@ -117,7 +117,7 @@ namespace clang {
/// Deprecated - Whether this the deprecated conversion of a
/// string literal to a pointer to non-const character data
/// (C++ 4.2p2).
- bool Deprecated : 1;
+ bool DeprecatedStringLiteralToCharPtr : 1;
/// IncompatibleObjC - Whether this is an Objective-C conversion
/// that we should warn about (if we actually use it).
OpenPOWER on IntegriCloud