Skip to content

Add guard to for loop test clang/test/Sema/for.c #133169

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

Ariel-Burton
Copy link
Contributor

Commit 20b7f59 includes a case that checks diagnostics for for loops using thread locals.
This fails on platforms which do not support TLS.
This change adds guards to run this part of the test iff the feature is supported.

Commit 20b7f59 includes a case that checks diagnostics for
for loops using thread locals.
This fails on platforms which do not support TLS.
This change adds guards to run this part of the test iff
the feature is supported.
@llvmbot llvmbot added the clang Clang issues not falling into any other category label Mar 26, 2025
@llvmbot
Copy link
Member

llvmbot commented Mar 26, 2025

@llvm/pr-subscribers-clang

Author: None (Ariel-Burton)

Changes

Commit 20b7f59 includes a case that checks diagnostics for for loops using thread locals.
This fails on platforms which do not support TLS.
This change adds guards to run this part of the test iff the feature is supported.


Full diff: https://github.com/llvm/llvm-project/pull/133169.diff

1 Files Affected:

  • (modified) clang/test/Sema/for.c (+3)
diff --git a/clang/test/Sema/for.c b/clang/test/Sema/for.c
index 110f84ddda952..33aaf7a074ad3 100644
--- a/clang/test/Sema/for.c
+++ b/clang/test/Sema/for.c
@@ -19,5 +19,8 @@ void b8 (void) { for (static struct { int i; } s;s.i;); } /* c11-warning {{decla
 void b9 (void) { for (struct { int i; } (*s)(struct { int j; } o) = 0;s;); }
 void b10(void) { for (typedef struct { int i; } (*s)(struct { int j; });;); } /* c11-warning {{non-variable declaration in 'for' loop is a C23 extension}}
                                                                                  c23-warning {{non-variable declaration in 'for' loop is incompatible with C standards before C23}} */
+
+#if __has_feature(c_thread_local)
 void b11 (void) { for (static _Thread_local struct { int i; } s;s.i;); } /* c11-warning {{declaration of non-local variable in 'for' loop is a C23 extension}}
                                                                             c23-warning {{declaration of non-local variable in 'for' loop is incompatible with C standards before C23}} */
+#endif

Copy link
Member

@Sirraide Sirraide left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I didn’t think of that. Thanks!

@perry-ca perry-ca merged commit fb993cd into llvm:main Mar 27, 2025
13 checks passed
@Ariel-Burton Ariel-Burton deleted the ariel/2025-03-26/guard-test-for-loop-thread-local branch March 27, 2025 20:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants