Module Name:    src
Committed By:   rillig
Date:           Sat Jul 15 16:17:38 UTC 2023

Modified Files:
        src/tests/usr.bin/xlint/lint1: c23.c
        src/usr.bin/xlint/lint1: decl.c

Log Message:
lint: allow 'extern' and 'thread_local' to be combined


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/xlint/lint1/c23.c
cvs rdiff -u -r1.359 -r1.360 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.4 src/tests/usr.bin/xlint/lint1/c23.c:1.5
--- src/tests/usr.bin/xlint/lint1/c23.c:1.4	Sat Jul 15 16:11:32 2023
+++ src/tests/usr.bin/xlint/lint1/c23.c	Sat Jul 15 16:17:38 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: c23.c,v 1.4 2023/07/15 16:11:32 rillig Exp $	*/
+/*	$NetBSD: c23.c,v 1.5 2023/07/15 16:17:38 rillig Exp $	*/
 # 3 "c23.c"
 
 // Tests for the option -Ac23, which allows features from C23 and all earlier
@@ -40,9 +40,7 @@ function(void)
 	thread_local int function_scoped_thread_local;
 }
 
-/* FIXME: 'thread_local' and 'extern' can be combined. */
-/* expect+1: error: only one storage class allowed [7] */
+// 'extern' and 'thread_local' can be combined.  The other storage classes
+// cannot be combined.
 extern thread_local int extern_thread_local_1;
-/* FIXME: 'thread_local' and 'extern' can be combined. */
-/* expect+1: error: only one storage class allowed [7] */
 thread_local extern int extern_thread_local_2;

Index: src/usr.bin/xlint/lint1/decl.c
diff -u src/usr.bin/xlint/lint1/decl.c:1.359 src/usr.bin/xlint/lint1/decl.c:1.360
--- src/usr.bin/xlint/lint1/decl.c:1.359	Sat Jul 15 15:38:03 2023
+++ src/usr.bin/xlint/lint1/decl.c	Sat Jul 15 16:17:37 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.359 2023/07/15 15:38:03 rillig Exp $ */
+/* $NetBSD: decl.c,v 1.360 2023/07/15 16:17:37 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.359 2023/07/15 15:38:03 rillig Exp $");
+__RCSID("$NetBSD: decl.c,v 1.360 2023/07/15 16:17:37 rillig Exp $");
 #endif
 
 #include <sys/param.h>
@@ -227,6 +227,9 @@ dcs_add_storage_class(scl_t sc)
 
 	if (dcs->d_scl == NOSCL)
 		dcs->d_scl = 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
 		dcs->d_multiple_storage_classes = true;
 }

Reply via email to