File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -109,6 +109,24 @@ TEST(ASTExpr, InitListIsConstantInitialized) {
109
109
EXPECT_FALSE (FooInit->isConstantInitializer (Ctx, false ));
110
110
}
111
111
112
+ TEST (ASTExpr, NoUnsignedOverflowICE) {
113
+ auto AST = buildASTFromCode (R"cpp(
114
+ unsigned u = 1u * 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 (8u , *ICE);
123
+
124
+ const auto ICEOverflowCheck = Var->getInit ()->getIntegerConstantExpr (Ctx, nullptr , true );
125
+ EXPECT_TRUE (ICEOverflowCheck.has_value ());
126
+ EXPECT_TRUE (ICEOverflowCheck->isUnsigned ());
127
+ EXPECT_EQ (8u , *ICEOverflowCheck);
128
+ }
129
+
112
130
TEST (ASTExpr, CheckForUnsignedOverflowICE) {
113
131
auto AST = buildASTFromCode (R"cpp(
114
132
unsigned u = 1'000'000'000u * 8u;
You can’t perform that action at this time.
0 commit comments