Revert r149359. This was a hack to a problem with an easy workaround, and it doesn't feel like general solution.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149404 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Ted Kremenek 2012-01-31 19:19:25 +00:00
Родитель 56e68b7129
Коммит 289e31f386
2 изменённых файлов: 4 добавлений и 34 удалений

Просмотреть файл

@ -3699,24 +3699,15 @@ static void AnalyzeAssignment(Sema &S, BinaryOperator *E) {
/// Diagnose an implicit cast; purely a helper for CheckImplicitConversion. /// Diagnose an implicit cast; purely a helper for CheckImplicitConversion.
static void DiagnoseImpCast(Sema &S, Expr *E, QualType SourceType, QualType T, static void DiagnoseImpCast(Sema &S, Expr *E, QualType SourceType, QualType T,
SourceLocation CContext, unsigned diag, SourceLocation CContext, unsigned diag) {
bool pruneControlFlow = false) {
if (pruneControlFlow) {
S.DiagRuntimeBehavior(E->getExprLoc(), E,
S.PDiag(diag)
<< SourceType << T << E->getSourceRange()
<< SourceRange(CContext));
return;
}
S.Diag(E->getExprLoc(), diag) S.Diag(E->getExprLoc(), diag)
<< SourceType << T << E->getSourceRange() << SourceRange(CContext); << SourceType << T << E->getSourceRange() << SourceRange(CContext);
} }
/// Diagnose an implicit cast; purely a helper for CheckImplicitConversion. /// Diagnose an implicit cast; purely a helper for CheckImplicitConversion.
static void DiagnoseImpCast(Sema &S, Expr *E, QualType T, static void DiagnoseImpCast(Sema &S, Expr *E, QualType T,
SourceLocation CContext, unsigned diag, SourceLocation CContext, unsigned diag) {
bool pruneControlFlow = false) { DiagnoseImpCast(S, E, E->getType(), T, CContext, diag);
DiagnoseImpCast(S, E, E->getType(), T, CContext, diag, pruneControlFlow);
} }
/// Diagnose an implicit cast from a literal expression. Does not warn when the /// Diagnose an implicit cast from a literal expression. Does not warn when the
@ -3922,8 +3913,7 @@ void CheckImplicitConversion(Sema &S, Expr *E, QualType T,
return; return;
if (SourceRange.Width == 64 && TargetRange.Width == 32) if (SourceRange.Width == 64 && TargetRange.Width == 32)
return DiagnoseImpCast(S, E, T, CC, diag::warn_impcast_integer_64_32, return DiagnoseImpCast(S, E, T, CC, diag::warn_impcast_integer_64_32);
/* pruneControlFlow */ true);
return DiagnoseImpCast(S, E, T, CC, diag::warn_impcast_integer_precision); return DiagnoseImpCast(S, E, T, CC, diag::warn_impcast_integer_precision);
} }

Просмотреть файл

@ -13,23 +13,3 @@ int4 test1(long2 a) {
int4 v127 = a; // no warning. int4 v127 = a; // no warning.
return v127; return v127;
} }
// <rdar://problem/10759934>
// Don't warn about -Wshorten-64-to-32 in unreachable code.
typedef unsigned int uint32_t;
typedef unsigned long long uint64_t;
int rdar10759934() {
uint32_t thing = 0;
uint64_t thing2 = 0;
switch (sizeof(thing2)) {
case 8:
break;
case 4:
thing = thing2; // no-warning
default:
break;
}
return 0;
}