[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
================
@@ -10267,6 +10267,9 @@ def ext_ms_anonymous_record : ExtWarn<
def err_reference_to_local_in_enclosing_context : Error<
"reference to local %select{variable|binding}1 %0 declared in enclosing "
"%select{%3|block literal|lambda expression|context}2">;
+def err_local_nested_class_invalid_scope : Error<
+ "nested local class %0 must be defined in the same block scope as "
----------------
Endilll wrote:
This message doesn't work when "parent" class is itself a nested class, because it's not necessarily defined at a block scope. I think it might be more useful to say "must be defined in the same block scope as %1", where %1 is the outermost local class.
https://github.com/llvm/llvm-project/pull/197863
More information about the cfe-commits
mailing list