mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-27 06:56:07 +00:00

Currently Sema::CheckForIntOverflow misses several case that other compilers diagnose for overflow in integral constant expressions. This includes the arguments of a CXXConstructExpr as well as the expressions used in an ArraySubscriptExpr, CXXNewExpr and CompoundLiteralExpr. This fixes https://github.com/llvm/llvm-project/issues/58944 Differential Revision: https://reviews.llvm.org/D137897
19 lines
638 B
C++
19 lines
638 B
C++
// RUN: %clang_cc1 %s -Wno-unused-value -verify -fsyntax-only
|
|
|
|
namespace GH58944 {
|
|
struct A {
|
|
A(unsigned long) ;
|
|
};
|
|
|
|
A a(1024 * 1024 * 1024 * 1024 * 1024ull); // expected-warning {{overflow in expression; result is 0 with type 'int'}}
|
|
|
|
void f() {
|
|
new int[1024 * 1024 * 1024 * 1024 * 1024ull]; // expected-warning {{overflow in expression; result is 0 with type 'int'}}
|
|
|
|
int arr[]{1,2,3};
|
|
arr[1024 * 1024 * 1024 * 1024 * 1024ull]; // expected-warning {{overflow in expression; result is 0 with type 'int'}}
|
|
|
|
(int){1024 * 1024 * 1024 * 1024 * 1024}; // expected-warning {{overflow in expression; result is 0 with type 'int'}}
|
|
}
|
|
}
|