File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -108,3 +108,19 @@ TEST(ASTExpr, InitListIsConstantInitialized) {
108
108
(void )FooInit->updateInit (Ctx, 2 , Ref);
109
109
EXPECT_FALSE (FooInit->isConstantInitializer (Ctx, false ));
110
110
}
111
+
112
+ TEST (ASTExpr, CheckForUnsignedOverflowICE) {
113
+ auto AST = buildASTFromCode (R"cpp(
114
+ unsigned u = 1'000'000'000u * 8u;
115
+ )cpp" );
116
+ ASTContext &Ctx = AST->getASTContext ();
117
+ const VarDecl *Var = getVariableNode (AST.get (), " u" );
118
+
119
+ const auto ICE = Var->getInit ()->getIntegerConstantExpr (Ctx);
120
+ EXPECT_TRUE (ICE.has_value ());
121
+ EXPECT_TRUE (ICE->isUnsigned ());
122
+ EXPECT_EQ (3'705'032'704u , *ICE);
123
+
124
+ const auto ICEOverflowCheck = Var->getInit ()->getIntegerConstantExpr (Ctx, nullptr , true );
125
+ EXPECT_FALSE (ICEOverflowCheck.has_value ());
126
+ }
You can’t perform that action at this time.
0 commit comments