Module Name:    src
Committed By:   rillig
Date:           Thu Jul 13 19:59:08 UTC 2023

Modified Files:
        src/tests/usr.bin/xlint/lint1: msg_010.c
        src/usr.bin/xlint/lint1: debug.c decl.c lex.c lint1.h

Log Message:
lint: _Thread_local is a storage class, not a type qualifier


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/tests/usr.bin/xlint/lint1/msg_010.c
cvs rdiff -u -r1.52 -r1.53 src/usr.bin/xlint/lint1/debug.c
cvs rdiff -u -r1.351 -r1.352 src/usr.bin/xlint/lint1/decl.c
cvs rdiff -u -r1.182 -r1.183 src/usr.bin/xlint/lint1/lex.c
cvs rdiff -u -r1.189 -r1.190 src/usr.bin/xlint/lint1/lint1.h

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/msg_010.c
diff -u src/tests/usr.bin/xlint/lint1/msg_010.c:1.6 src/tests/usr.bin/xlint/lint1/msg_010.c:1.7
--- src/tests/usr.bin/xlint/lint1/msg_010.c:1.6	Tue Mar 28 14:44:34 2023
+++ src/tests/usr.bin/xlint/lint1/msg_010.c	Thu Jul 13 19:59:08 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: msg_010.c,v 1.6 2023/03/28 14:44:34 rillig Exp $	*/
+/*	$NetBSD: msg_010.c,v 1.7 2023/07/13 19:59:08 rillig Exp $	*/
 # 3 "msg_010.c"
 
 // Test for message: duplicate '%s' [10]
@@ -34,8 +34,9 @@ restrict_pointer(const int *restrict p)
 _Thread_local int thread_local_int;
 _Thread_local int *pointer_to_thread_local;
 
+/* expect+2: error: only 'register' is valid as storage class in parameter [9] */
 int
-thread_local_parameter(_Thread_local int i) /* caught by the compiler */
+thread_local_parameter(_Thread_local int i)
 {
 	return i;
 }

Index: src/usr.bin/xlint/lint1/debug.c
diff -u src/usr.bin/xlint/lint1/debug.c:1.52 src/usr.bin/xlint/lint1/debug.c:1.53
--- src/usr.bin/xlint/lint1/debug.c:1.52	Wed Jul 12 19:34:01 2023
+++ src/usr.bin/xlint/lint1/debug.c	Thu Jul 13 19:59:08 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: debug.c,v 1.52 2023/07/12 19:34:01 rillig Exp $ */
+/* $NetBSD: debug.c,v 1.53 2023/07/13 19:59:08 rillig Exp $ */
 
 /*-
  * Copyright (c) 2021 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID)
-__RCSID("$NetBSD: debug.c,v 1.52 2023/07/12 19:34:01 rillig Exp $");
+__RCSID("$NetBSD: debug.c,v 1.53 2023/07/13 19:59:08 rillig Exp $");
 #endif
 
 #include <stdlib.h>
@@ -275,6 +275,7 @@ scl_name(scl_t scl)
 		"auto",
 		"register",
 		"typedef",
+		"thread_local",
 		"struct",
 		"union",
 		"enum",
@@ -308,7 +309,6 @@ tqual_name(tqual_t qual)
 		"const",
 		"volatile",
 		"restrict",
-		"_Thread_local",
 		"_Atomic",
 	};
 

Index: src/usr.bin/xlint/lint1/decl.c
diff -u src/usr.bin/xlint/lint1/decl.c:1.351 src/usr.bin/xlint/lint1/decl.c:1.352
--- src/usr.bin/xlint/lint1/decl.c:1.351	Thu Jul 13 08:40:38 2023
+++ src/usr.bin/xlint/lint1/decl.c	Thu Jul 13 19:59:08 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.351 2023/07/13 08:40:38 rillig Exp $ */
+/* $NetBSD: decl.c,v 1.352 2023/07/13 19:59:08 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.351 2023/07/13 08:40:38 rillig Exp $");
+__RCSID("$NetBSD: decl.c,v 1.352 2023/07/13 19:59:08 rillig Exp $");
 #endif
 
 #include <sys/param.h>
@@ -515,7 +515,7 @@ dcs_add_qualifier(tqual_t q)
 		}
 		dcs->d_volatile = true;
 	} else {
-		lint_assert(q == RESTRICT || q == THREAD || q == ATOMIC);
+		lint_assert(q == RESTRICT || q == ATOMIC);
 		/* Silently ignore these qualifiers. */
 	}
 }
@@ -1448,10 +1448,7 @@ check_function_definition(sym_t *sym, bo
 	}
 }
 
-/*
- * Process the name in a declarator. The symbol gets one of the storage classes
- * EXTERN, STATIC, AUTO or TYPEDEF, as well as a definedness in 's_def'.
- */
+/* The symbol gets a storage class and a definedness. */
 sym_t *
 declarator_name(sym_t *sym)
 {
@@ -1476,13 +1473,13 @@ declarator_name(sym_t *sym)
 		break;
 	case DLK_EXTERN:
 		/*
-		 * static and external symbols without "extern" are considered
-		 * to be tentatively defined, external symbols with "extern"
-		 * are declared, and typedef names are defined. Tentatively
-		 * defined and declared symbols may become defined if an
-		 * initializer is present or this is a function definition.
+		 * Symbols that are 'static' or without any storage class are
+		 * tentatively defined. Symbols that are tentatively defined or
+		 * declared may later become defined if an initializer is seen
+		 * or this is a function definition.
 		 */
-		if ((sc = dcs->d_scl) == NOSCL) {
+		sc = dcs->d_scl;
+		if (sc == NOSCL || sc == THREAD_LOCAL) {
 			sc = EXTERN;
 			sym->s_def = TDEF;
 		} else if (sc == STATIC)

Index: src/usr.bin/xlint/lint1/lex.c
diff -u src/usr.bin/xlint/lint1/lex.c:1.182 src/usr.bin/xlint/lint1/lex.c:1.183
--- src/usr.bin/xlint/lint1/lex.c:1.182	Thu Jul 13 08:40:38 2023
+++ src/usr.bin/xlint/lint1/lex.c	Thu Jul 13 19:59:08 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: lex.c,v 1.182 2023/07/13 08:40:38 rillig Exp $ */
+/* $NetBSD: lex.c,v 1.183 2023/07/13 19:59:08 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -38,7 +38,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID)
-__RCSID("$NetBSD: lex.c,v 1.182 2023/07/13 08:40:38 rillig Exp $");
+__RCSID("$NetBSD: lex.c,v 1.183 2023/07/13 19:59:08 rillig Exp $");
 #endif
 
 #include <ctype.h>
@@ -162,9 +162,8 @@ static const struct keyword {
 	kwdef("struct",	T_STRUCT_OR_UNION, .u.kw_tspec = STRUCT, 78,0,1),
 	kwdef_keyword(	"switch",	T_SWITCH),
 	kwdef_token(	"__symbolrename",	T_SYMBOLRENAME,	78,0,1),
-	kwdef_tqual(	"__thread",	THREAD,			78,1,1),
-	/* XXX: _Thread_local is a storage-class-specifier, not tqual. */
-	kwdef_tqual(	"_Thread_local", THREAD,		11,0,1),
+	kwdef_sclass(	"__thread",	THREAD_LOCAL,		78,1,1),
+	kwdef_sclass(	"_Thread_local", THREAD_LOCAL,		11,0,1),
 	kwdef_sclass(	"typedef",	TYPEDEF,		78,0,1),
 	kwdef_token(	"typeof",	T_TYPEOF,		78,1,7),
 #ifdef INT128_SIZE

Index: src/usr.bin/xlint/lint1/lint1.h
diff -u src/usr.bin/xlint/lint1/lint1.h:1.189 src/usr.bin/xlint/lint1/lint1.h:1.190
--- src/usr.bin/xlint/lint1/lint1.h:1.189	Thu Jul 13 08:40:38 2023
+++ src/usr.bin/xlint/lint1/lint1.h	Thu Jul 13 19:59:08 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: lint1.h,v 1.189 2023/07/13 08:40:38 rillig Exp $ */
+/* $NetBSD: lint1.h,v 1.190 2023/07/13 19:59:08 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -79,14 +79,11 @@ typedef	struct strg {
 	void	*st_mem;	/* char[] for st_char, or wchar_t[] */
 } strg_t;
 
-/*
- * qualifiers (only for lex/yacc interface)
- */
+/* type qualifiers (only used during parsing) */
 typedef enum {
 	CONST,
 	VOLATILE,
 	RESTRICT,
-	THREAD,			/* XXX: storage-class-qualifier */
 	ATOMIC,
 } tqual_t;
 
@@ -198,6 +195,7 @@ typedef enum {
 	AUTO,		/* automatic symbols (except register) */
 	REG,		/* register */
 	TYPEDEF,	/* typedef */
+	THREAD_LOCAL,
 	STRUCT_TAG,
 	UNION_TAG,
 	ENUM_TAG,

Reply via email to