Module Name: src
Committed By: rillig
Date: Tue Jul 25 16:56:35 UTC 2023
Modified Files:
src/tests/usr.bin/xlint/lint1: c23.c
src/usr.bin/xlint/lint1: decl.c
Log Message:
lint: allow 'thread_local' to be combined with 'static'
To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/tests/usr.bin/xlint/lint1/c23.c
cvs rdiff -u -r1.361 -r1.362 src/usr.bin/xlint/lint1/decl.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/tests/usr.bin/xlint/lint1/c23.c
diff -u src/tests/usr.bin/xlint/lint1/c23.c:1.5 src/tests/usr.bin/xlint/lint1/c23.c:1.6
--- src/tests/usr.bin/xlint/lint1/c23.c:1.5 Sat Jul 15 16:17:38 2023
+++ src/tests/usr.bin/xlint/lint1/c23.c Tue Jul 25 16:56:35 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: c23.c,v 1.5 2023/07/15 16:17:38 rillig Exp $ */
+/* $NetBSD: c23.c,v 1.6 2023/07/25 16:56:35 rillig Exp $ */
# 3 "c23.c"
// Tests for the option -Ac23, which allows features from C23 and all earlier
@@ -40,7 +40,11 @@ function(void)
thread_local int function_scoped_thread_local;
}
-// 'extern' and 'thread_local' can be combined. The other storage classes
-// cannot be combined.
+// 'thread_local' can be combined with 'extern' and 'static', but with no other
+// storage classes. The other storage classes cannot be combined.
extern thread_local int extern_thread_local_1;
thread_local extern int extern_thread_local_2;
+static thread_local int static_thread_local_1;
+thread_local static int static_thread_local_2;
+/* expect-2: warning: static variable 'static_thread_local_1' unused [226] */
+/* expect-2: warning: static variable 'static_thread_local_2' unused [226] */
Index: src/usr.bin/xlint/lint1/decl.c
diff -u src/usr.bin/xlint/lint1/decl.c:1.361 src/usr.bin/xlint/lint1/decl.c:1.362
--- src/usr.bin/xlint/lint1/decl.c:1.361 Tue Jul 18 03:00:42 2023
+++ src/usr.bin/xlint/lint1/decl.c Tue Jul 25 16:56:35 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.361 2023/07/18 03:00:42 rin Exp $ */
+/* $NetBSD: decl.c,v 1.362 2023/07/25 16:56:35 rillig Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
@@ -38,7 +38,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID)
-__RCSID("$NetBSD: decl.c,v 1.361 2023/07/18 03:00:42 rin Exp $");
+__RCSID("$NetBSD: decl.c,v 1.362 2023/07/25 16:56:35 rillig Exp $");
#endif
#include <sys/param.h>
@@ -226,6 +226,9 @@ dcs_add_storage_class(scl_t sc)
else if ((dcs->d_scl == EXTERN && sc == THREAD_LOCAL)
|| (dcs->d_scl == THREAD_LOCAL && sc == EXTERN))
dcs->d_scl = EXTERN; /* ignore thread_local */
+ else if ((dcs->d_scl == STATIC && sc == THREAD_LOCAL)
+ || (dcs->d_scl == THREAD_LOCAL && sc == STATIC))
+ dcs->d_scl = STATIC; /* ignore thread_local */
else
dcs->d_multiple_storage_classes = true;
}