[clang] [ExprConstant] Handle shift overflow the same way as other kinds of overflow (PR #99579)

Eli Friedman via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 18 16:47:09 PDT 2024


================
@@ -142,7 +142,7 @@ constexpr int arb(int n) { // expected-note {{declared here}}
                expected-note {{function parameter 'n' with unknown value cannot be used in a constant expression}}
 }
 constexpr long Overflow[(1 << 30) << 2]{}; // expected-warning {{requires 34 bits to represent}} \
-                                              expected-warning {{variable length array folded to constant array as an extension}} \
+                                              expected-error {{variable length array declaration not allowed at file scope}} \
----------------
efriedma-quic wrote:

It depends on what the caller asks for.  TryToFixInvalidVariablyModifiedType calls EvaluateAsInt directly in a mode that doesn't allow undefined behavior, so it's just treated as an unevaluatable expression.  A few other places use CheckConvertedConstantExpression, which is also strict.  Enumerators go through VerifyIntegerConstantExpression, which is not strict.

https://github.com/llvm/llvm-project/pull/99579


More information about the cfe-commits mailing list