Author: Oliver Hunt
Date: 2026-08-31T00:52:52-07:00
New Revision: bfe1283da4922ed313e6bd4dcc3c6a1bcf40e0b0

URL: 
https://github.com/llvm/llvm-project/commit/bfe1283da4922ed313e6bd4dcc3c6a1bcf40e0b0
DIFF: 
https://github.com/llvm/llvm-project/commit/bfe1283da4922ed313e6bd4dcc3c6a1bcf40e0b0.diff

LOG: [Sema][NFC] Add additional tests for declarations in expansion statements 
(#211948)

I came up with these additional tests for declarations in expansion
statements that previously failed but now correctly diagnose the errors.

Added: 
    

Modified: 
    clang/test/SemaCXX/expansion-statements-local-extern-decls.cpp

Removed: 
    


################################################################################
diff  --git a/clang/test/SemaCXX/expansion-statements-local-extern-decls.cpp 
b/clang/test/SemaCXX/expansion-statements-local-extern-decls.cpp
index c00a9c400c24d..6e16090b960ec 100644
--- a/clang/test/SemaCXX/expansion-statements-local-extern-decls.cpp
+++ b/clang/test/SemaCXX/expansion-statements-local-extern-decls.cpp
@@ -71,3 +71,29 @@ void foo6() {
     // expected-note@#duplicate_global_function_decl {{previous declaration is 
here}}
   }
 }
+void foo7() {
+  template for (constexpr auto x : {true, false}) { // #foo7_instantiation
+    if constexpr (x) {
+      extern int qualified_decl; // #first_qualified_decl
+    } else {
+      extern thread_local int qualified_decl; // #mismatched_qualified_decl
+      // expected-error@#mismatched_qualified_decl {{thread-local declaration 
of 'qualified_decl' follows non-thread-local declaration}}
+      // expected-note@#foo7_instantiation {{in instantiation of expansion 
statement requested here}}
+      // expected-note@#first_qualified_decl {{previous declaration is here}}
+    }
+  }
+}
+
+int foo8_decl; // #foo8_decl
+void foo8() {
+  template for (constexpr auto x : {true, false}) { // #foo8_instantiation
+    if constexpr (x) {
+      extern int foo8_decl;
+    } else {
+      extern thread_local int foo8_decl; // #mismatched_foo8_decl
+      // expected-error@#mismatched_foo8_decl {{thread-local declaration of 
'foo8_decl' follows non-thread-local declaration}}
+      // expected-note@#foo8_instantiation {{in instantiation of expansion 
statement requested here}}
+      // expected-note@#foo8_decl {{previous definition is here}}
+    }
+  }
+}


        
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to