This revision was automatically updated to reflect the committed changes. Closed by commit rG6333871f8540: Add diagnostic for for-range-declaration being specificed with thread_local (authored by shafik). Herald added a project: clang.
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D92671/new/ https://reviews.llvm.org/D92671 Files: clang/include/clang/Basic/DiagnosticSemaKinds.td clang/lib/Sema/SemaDecl.cpp clang/test/CXX/stmt.stmt/stmt.iter/stmt.ranged/p1.cpp Index: clang/test/CXX/stmt.stmt/stmt.iter/stmt.ranged/p1.cpp =================================================================== --- clang/test/CXX/stmt.stmt/stmt.iter/stmt.ranged/p1.cpp +++ clang/test/CXX/stmt.stmt/stmt.iter/stmt.ranged/p1.cpp @@ -151,6 +151,7 @@ for (extern int a : A()) {} // expected-error {{loop variable 'a' may not be declared 'extern'}} for (static int a : A()) {} // expected-error {{loop variable 'a' may not be declared 'static'}} + for (thread_local int a : A()) {} // expected-error {{loop variable 'a' may not be declared 'thread_local'}} for (register int a : A()) {} // expected-error {{loop variable 'a' may not be declared 'register'}} expected-warning 0-1{{register}} expected-error 0-1{{register}} for (constexpr int a : X::C()) {} // OK per CWG issue #1204. Index: clang/lib/Sema/SemaDecl.cpp =================================================================== --- clang/lib/Sema/SemaDecl.cpp +++ clang/lib/Sema/SemaDecl.cpp @@ -12782,6 +12782,18 @@ Error = 4; break; } + + // for-range-declaration cannot be given a storage class specifier con't. + switch (VD->getTSCSpec()) { + case TSCS_thread_local: + Error = 6; + break; + case TSCS___thread: + case TSCS__Thread_local: + case TSCS_unspecified: + break; + } + if (Error != -1) { Diag(VD->getOuterLocStart(), diag::err_for_range_storage_class) << VD << Error; Index: clang/include/clang/Basic/DiagnosticSemaKinds.td =================================================================== --- clang/include/clang/Basic/DiagnosticSemaKinds.td +++ clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -2448,7 +2448,7 @@ "for range declaration must declare a variable">; def err_for_range_storage_class : Error< "loop variable %0 may not be declared %select{'extern'|'static'|" - "'__private_extern__'|'auto'|'register'|'constexpr'}1">; + "'__private_extern__'|'auto'|'register'|'constexpr'|'thread_local'}1">; def err_type_defined_in_for_range : Error< "types may not be defined in a for range declaration">; def err_for_range_deduction_failure : Error<
Index: clang/test/CXX/stmt.stmt/stmt.iter/stmt.ranged/p1.cpp =================================================================== --- clang/test/CXX/stmt.stmt/stmt.iter/stmt.ranged/p1.cpp +++ clang/test/CXX/stmt.stmt/stmt.iter/stmt.ranged/p1.cpp @@ -151,6 +151,7 @@ for (extern int a : A()) {} // expected-error {{loop variable 'a' may not be declared 'extern'}} for (static int a : A()) {} // expected-error {{loop variable 'a' may not be declared 'static'}} + for (thread_local int a : A()) {} // expected-error {{loop variable 'a' may not be declared 'thread_local'}} for (register int a : A()) {} // expected-error {{loop variable 'a' may not be declared 'register'}} expected-warning 0-1{{register}} expected-error 0-1{{register}} for (constexpr int a : X::C()) {} // OK per CWG issue #1204. Index: clang/lib/Sema/SemaDecl.cpp =================================================================== --- clang/lib/Sema/SemaDecl.cpp +++ clang/lib/Sema/SemaDecl.cpp @@ -12782,6 +12782,18 @@ Error = 4; break; } + + // for-range-declaration cannot be given a storage class specifier con't. + switch (VD->getTSCSpec()) { + case TSCS_thread_local: + Error = 6; + break; + case TSCS___thread: + case TSCS__Thread_local: + case TSCS_unspecified: + break; + } + if (Error != -1) { Diag(VD->getOuterLocStart(), diag::err_for_range_storage_class) << VD << Error; Index: clang/include/clang/Basic/DiagnosticSemaKinds.td =================================================================== --- clang/include/clang/Basic/DiagnosticSemaKinds.td +++ clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -2448,7 +2448,7 @@ "for range declaration must declare a variable">; def err_for_range_storage_class : Error< "loop variable %0 may not be declared %select{'extern'|'static'|" - "'__private_extern__'|'auto'|'register'|'constexpr'}1">; + "'__private_extern__'|'auto'|'register'|'constexpr'|'thread_local'}1">; def err_type_defined_in_for_range : Error< "types may not be defined in a for range declaration">; def err_for_range_deduction_failure : Error<
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits