xbolva00 updated this revision to Diff 167835. xbolva00 added a comment. Fixed crash
https://reviews.llvm.org/D52750 Files: lib/Sema/SemaType.cpp test/Sema/integer-overflow.c Index: test/Sema/integer-overflow.c =================================================================== --- test/Sema/integer-overflow.c +++ test/Sema/integer-overflow.c @@ -172,6 +172,9 @@ // expected-warning@+1 {{overflow in expression; result is 536870912 with type 'int'}} (void)f2(0, f0(4608 * 1024 * 1024)); } +void check_integer_overflows_in_array_size() { + int arr[4608 * 1024 * 1024]; // expected-warning {{overflow in expression; result is 536870912 with type 'int'}} +} struct s { unsigned x; Index: lib/Sema/SemaType.cpp =================================================================== --- lib/Sema/SemaType.cpp +++ lib/Sema/SemaType.cpp @@ -2082,7 +2082,8 @@ QualType Sema::BuildArrayType(QualType T, ArrayType::ArraySizeModifier ASM, Expr *ArraySize, unsigned Quals, SourceRange Brackets, DeclarationName Entity) { - + if (ArraySize && isa<BinaryOperator>(ArraySize)) + ArraySize->EvaluateForOverflow(Context); SourceLocation Loc = Brackets.getBegin(); if (getLangOpts().CPlusPlus) { // C++ [dcl.array]p1:
Index: test/Sema/integer-overflow.c =================================================================== --- test/Sema/integer-overflow.c +++ test/Sema/integer-overflow.c @@ -172,6 +172,9 @@ // expected-warning@+1 {{overflow in expression; result is 536870912 with type 'int'}} (void)f2(0, f0(4608 * 1024 * 1024)); } +void check_integer_overflows_in_array_size() { + int arr[4608 * 1024 * 1024]; // expected-warning {{overflow in expression; result is 536870912 with type 'int'}} +} struct s { unsigned x; Index: lib/Sema/SemaType.cpp =================================================================== --- lib/Sema/SemaType.cpp +++ lib/Sema/SemaType.cpp @@ -2082,7 +2082,8 @@ QualType Sema::BuildArrayType(QualType T, ArrayType::ArraySizeModifier ASM, Expr *ArraySize, unsigned Quals, SourceRange Brackets, DeclarationName Entity) { - + if (ArraySize && isa<BinaryOperator>(ArraySize)) + ArraySize->EvaluateForOverflow(Context); SourceLocation Loc = Brackets.getBegin(); if (getLangOpts().CPlusPlus) { // C++ [dcl.array]p1:
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits