diff options
author | John McCall <rjmccall@apple.com> | 2010-08-12 21:44:57 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2010-08-12 21:44:57 +0000 |
commit | b7f4ffe073fa419613946461a2583ba2fcb72280 (patch) | |
tree | 07313f9efdc7b99a8430133c2f5de020e1762015 /lib/Sema/SemaCXXCast.cpp | |
parent | d69fd7f34fd2de35845e834e987009efec09b937 (diff) |
Implement -Wcast-align. The initial design of this diagnostic diverges
from GCC's in that we warn on *any* increase in alignment requirements, not
just those that are enforced by hardware. Please let us know if this causes
major problems for you (which it shouldn't, since it's an optional warning).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110959 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaCXXCast.cpp')
-rw-r--r-- | lib/Sema/SemaCXXCast.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/Sema/SemaCXXCast.cpp b/lib/Sema/SemaCXXCast.cpp index 5753e7bce4..59df294772 100644 --- a/lib/Sema/SemaCXXCast.cpp +++ b/lib/Sema/SemaCXXCast.cpp @@ -468,6 +468,8 @@ CheckReinterpretCast(Sema &Self, Expr *&SrcExpr, QualType DestType, != TC_Success && msg != 0) Self.Diag(OpRange.getBegin(), msg) << CT_Reinterpret << SrcExpr->getType() << DestType << OpRange; + else if (Kind == CastExpr::CK_Unknown || Kind == CastExpr::CK_BitCast) + Self.CheckCastAlign(SrcExpr, DestType, OpRange); } @@ -494,6 +496,8 @@ CheckStaticCast(Sema &Self, Expr *&SrcExpr, QualType DestType, Kind, BasePath) != TC_Success && msg != 0) Self.Diag(OpRange.getBegin(), msg) << CT_Static << SrcExpr->getType() << DestType << OpRange; + else if (Kind == CastExpr::CK_Unknown || Kind == CastExpr::CK_BitCast) + Self.CheckCastAlign(SrcExpr, DestType, OpRange); } /// TryStaticCast - Check if a static cast can be performed, and do so if @@ -1303,6 +1307,8 @@ Sema::CXXCheckCStyleCast(SourceRange R, QualType CastTy, Expr *&CastExpr, if (tcr != TC_Success && msg != 0) Diag(R.getBegin(), msg) << (FunctionalStyle ? CT_Functional : CT_CStyle) << CastExpr->getType() << CastTy << R; + else if (Kind == CastExpr::CK_Unknown || Kind == CastExpr::CK_BitCast) + CheckCastAlign(CastExpr, CastTy, R); return tcr != TC_Success; } |