[clang] [clang-repl] Names declared in if conditions and for-init statements are local to the inner context (C++ 3.3.2p4) (PR #84150)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 6 05:14:18 PST 2024


Stefan =?utf-8?q?Gränitz?= <stefan.graenitz at gmail.com>,
Stefan =?utf-8?q?Gränitz?= <stefan.graenitz at gmail.com>,
Stefan =?utf-8?q?Gränitz?= <stefan.graenitz at gmail.com>,
Stefan =?utf-8?q?Gränitz?= <stefan.graenitz at gmail.com>,
Stefan =?utf-8?q?Gränitz?= <stefan.graenitz at gmail.com>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/84150 at github.com>


================
@@ -41,3 +40,16 @@ for (; i > 4; --i) { printf("i = %d\n", i); };
 
 int j = i; printf("j = %d\n", j);
 // CHECK-NEXT: j = 4
+
+if (int i = j) printf("i = %d\n", i);
----------------
AaronBallman wrote:

You should add a test with a `while` loop and an empty body (that also requires a compound scope, similar to `for`).

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


More information about the cfe-commits mailing list