[clang] [clang][Sema] Diagnose nested local classes defined in a different block scope than their parent (PR #197863)
Vlad Serebrennikov via cfe-commits
cfe-commits at lists.llvm.org
Fri May 15 01:51:58 PDT 2026
================
@@ -1,30 +1,91 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
-
-void f1() {
- struct X {
- struct Y;
- };
-
- struct X::Y {
- void f() {}
- };
-}
-
-void f2() {
- struct X {
- struct Y;
-
- struct Y {
- void f() {}
- };
- };
-}
-
-// A class nested within a local class is a local class.
-void f3(int a) { // expected-note{{'a' declared here}}
- struct X {
- struct Y {
- int f() { return a; } // expected-error{{reference to local variable 'a' declared in enclosing function 'f3'}}
- };
- };
-}
+// RUN: %clang_cc1 -fsyntax-only -verify %s
----------------
Endilll wrote:
Can you switch this test to `-verify-directives`? In general I think this test would benefit from C++ DR test conventions, like `@-1`.
https://github.com/llvm/llvm-project/pull/197863
More information about the cfe-commits
mailing list