[llvm] Move static test variable into the #if that uses it (PR #169695)

Justin Bogner via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 26 09:43:40 PST 2025


https://github.com/bogner created https://github.com/llvm/llvm-project/pull/169695

Fixes -Wunused-variable when compiling without LLVM_ENABLE_THREADS

>From 4dbbbb819fa4f471c29ee5ca23be77fb37f46429 Mon Sep 17 00:00:00 2001
From: Justin Bogner <mail at justinbogner.com>
Date: Wed, 26 Nov 2025 09:24:14 -0800
Subject: [PATCH] Move static test variable into the #if that uses it

Fixes -Wunused-variable when compiling without LLVM_ENABLE_THREADS
---
 llvm/unittests/Support/JobserverTest.cpp | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/llvm/unittests/Support/JobserverTest.cpp b/llvm/unittests/Support/JobserverTest.cpp
index 1917145704608..df623463bb309 100644
--- a/llvm/unittests/Support/JobserverTest.cpp
+++ b/llvm/unittests/Support/JobserverTest.cpp
@@ -46,9 +46,6 @@ extern const char *TestMainArgv0;
 
 namespace {
 
-// Unique anchor whose address helps locate the current test binary.
-static int JobserverTestAnchor = 0;
-
 // RAII helper to set an environment variable for the duration of a test.
 class ScopedEnvironment {
   std::string Name;
@@ -225,6 +222,9 @@ TEST_F(JobserverClientTest, UnixClientFifo) {
 }
 
 #if LLVM_ENABLE_THREADS
+// Unique anchor whose address helps locate the current test binary.
+static int JobserverTestAnchor = 0;
+
 // Test fixture for tests that use the jobserver strategy. It creates a
 // temporary FIFO, sets MAKEFLAGS, and provides a helper to pre-load the FIFO
 // with job tokens, simulating `make -jN`.



More information about the llvm-commits mailing list