diff options
| author | Akira Hatanaka <ahatanaka@apple.com> | 2016-01-11 17:22:01 +0000 |
|---|---|---|
| committer | Akira Hatanaka <ahatanaka@apple.com> | 2016-01-11 17:22:01 +0000 |
| commit | f5c136186f4f6b1c3b2bb4b2e7a57496592a0117 (patch) | |
| tree | f557cfce16e5751dc29dc8c6f9ab6675efd4b7d4 /clang/lib/Sema | |
| parent | 7af056280840836a661b1ab000ed41d5ab121d8f (diff) | |
| download | bcm5719-llvm-f5c136186f4f6b1c3b2bb4b2e7a57496592a0117.tar.gz bcm5719-llvm-f5c136186f4f6b1c3b2bb4b2e7a57496592a0117.zip | |
[Sema] Issue a warning for integer overflow in struct initializer
Clang wasn't issuing a warning when compiling the following code:
struct s {
unsigned x;
} s = {
.x = 4 * 1024 * 1024 * 1024
};
rdar://problem/23399683
Differential Revision: http://reviews.llvm.org/D15097
llvm-svn: 257357
Diffstat (limited to 'clang/lib/Sema')
| -rw-r--r-- | clang/lib/Sema/SemaChecking.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp index 98c9ceb1d65..4680bcd11d0 100644 --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -7853,6 +7853,10 @@ void Sema::CheckBoolLikeConversion(Expr *E, SourceLocation CC) { void Sema::CheckForIntOverflow (Expr *E) { if (isa<BinaryOperator>(E->IgnoreParenCasts())) E->IgnoreParenCasts()->EvaluateForOverflow(Context); + else if (auto InitList = dyn_cast<InitListExpr>(E)) + for (Expr *E : InitList->inits()) + if (isa<BinaryOperator>(E->IgnoreParenCasts())) + E->IgnoreParenCasts()->EvaluateForOverflow(Context); } namespace { |

