Nothing particularly special. There is a performance cost to doing this, so I was being frugal on how inclusive this should be. We can always adjust later if users ask for it. Do you feel strongly about pulling all -Wconversion warnings in?
On Jan 30, 2012, at 9:50 PM, Eli Friedman wrote: > On Mon, Jan 30, 2012 at 9:37 PM, Ted Kremenek <[email protected]> wrote: >> Author: kremenek >> Date: Mon Jan 30 23:37:48 2012 >> New Revision: 149359 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=149359&view=rev >> Log: >> Don't warn about -Wshorten-64-to-32 in unreachable code. Fixes >> <rdar://problem/10759934>. Apparently this is a common idiom in Linux >> (among other places). >> >> Modified: >> cfe/trunk/lib/Sema/SemaChecking.cpp >> cfe/trunk/test/Sema/conversion-64-32.c >> >> Modified: cfe/trunk/lib/Sema/SemaChecking.cpp >> URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=149359&r1=149358&r2=149359&view=diff >> ============================================================================== >> --- cfe/trunk/lib/Sema/SemaChecking.cpp (original) >> +++ cfe/trunk/lib/Sema/SemaChecking.cpp Mon Jan 30 23:37:48 2012 >> @@ -3693,15 +3693,24 @@ >> >> /// Diagnose an implicit cast; purely a helper for CheckImplicitConversion. >> 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) >> << SourceType << T << E->getSourceRange() << SourceRange(CContext); >> } >> >> /// Diagnose an implicit cast; purely a helper for CheckImplicitConversion. >> static void DiagnoseImpCast(Sema &S, Expr *E, QualType T, >> - SourceLocation CContext, unsigned diag) { >> - DiagnoseImpCast(S, E, E->getType(), T, CContext, diag); >> + SourceLocation CContext, unsigned diag, >> + bool pruneControlFlow = false) { >> + DiagnoseImpCast(S, E, E->getType(), T, CContext, diag, pruneControlFlow); >> } >> >> /// Diagnose an implicit cast from a literal expression. Does not warn when >> the >> @@ -3907,7 +3916,8 @@ >> return; >> >> 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); >> } > > Why is -Wshorten-64-to-32 special here? Why not suppress all > -Wconversion warnings in unreachable code? > > -Eli _______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
