Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/xlint/lint1 lint: allow 'thread_local' to be combine...



details:   https://anonhg.NetBSD.org/src/rev/6c41117dbaf3
branches:  trunk
changeset: 378191:6c41117dbaf3
user:      rillig <rillig%NetBSD.org@localhost>
date:      Tue Jul 25 16:56:35 2023 +0000

description:
lint: allow 'thread_local' to be combined with 'static'

diffstat:

 tests/usr.bin/xlint/lint1/c23.c |  10 +++++++---
 usr.bin/xlint/lint1/decl.c      |   7 +++++--
 2 files changed, 12 insertions(+), 5 deletions(-)

diffs (51 lines):

diff -r f09c43919bd8 -r 6c41117dbaf3 tests/usr.bin/xlint/lint1/c23.c
--- a/tests/usr.bin/xlint/lint1/c23.c   Tue Jul 25 16:15:50 2023 +0000
+++ b/tests/usr.bin/xlint/lint1/c23.c   Tue Jul 25 16:56:35 2023 +0000
@@ -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] */
diff -r f09c43919bd8 -r 6c41117dbaf3 usr.bin/xlint/lint1/decl.c
--- a/usr.bin/xlint/lint1/decl.c        Tue Jul 25 16:15:50 2023 +0000
+++ b/usr.bin/xlint/lint1/decl.c        Tue Jul 25 16:56:35 2023 +0000
@@ -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;
 }



Home | Main Index | Thread Index | Old Index