From 0e6901421247b1c7ce0a2e925666d5314a34fffa Mon Sep 17 00:00:00 2001 From: =?utf8?q?Timm=20B=C3=A4der?= Date: Fri, 30 Sep 2022 12:04:28 +0200 Subject: [PATCH] [clang][Interp][NFC] Add a failing test case --- clang/test/AST/Interp/cxx20.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/clang/test/AST/Interp/cxx20.cpp b/clang/test/AST/Interp/cxx20.cpp index e088f6b..1b1a613 100644 --- a/clang/test/AST/Interp/cxx20.cpp +++ b/clang/test/AST/Interp/cxx20.cpp @@ -60,3 +60,21 @@ constexpr int unInitLocal() { static_assert(unInitLocal() == 0, ""); // expected-error {{not an integral constant expression}} \ // ref-error {{not an integral constant expression}} \ // ref-note {{in call to 'unInitLocal()'}} + +/// TODO: The example above is correctly rejected by the new constexpr +/// interpreter, but for the wrong reasons. We don't reject it because +/// it is an uninitialized read, we reject it simply because +/// the local variable does not have an initializer. +/// +/// The code below should be accepted but is also being rejected +/// right now. +#if 0 +constexpr int initializedLocal() { + int a; + int b; + + a = 20; + return a; +} +static_assert(initializedLocal() == 20); +#endif -- 2.7.4