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

This commit is contained in:
rillig 2023-07-13 19:59:08 +00:00
parent de4f7393da
commit fe2ba0d5e5
5 changed files with 23 additions and 28 deletions

View File

@ -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" # 3 "msg_010.c"
// Test for message: duplicate '%s' [10] // 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 thread_local_int;
_Thread_local int *pointer_to_thread_local; _Thread_local int *pointer_to_thread_local;
/* expect+2: error: only 'register' is valid as storage class in parameter [9] */
int int
thread_local_parameter(_Thread_local int i) /* caught by the compiler */ thread_local_parameter(_Thread_local int i)
{ {
return i; return i;
} }

View File

@ -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. * Copyright (c) 2021 The NetBSD Foundation, Inc.
@ -35,7 +35,7 @@
#include <sys/cdefs.h> #include <sys/cdefs.h>
#if defined(__RCSID) #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 #endif
#include <stdlib.h> #include <stdlib.h>
@ -275,6 +275,7 @@ scl_name(scl_t scl)
"auto", "auto",
"register", "register",
"typedef", "typedef",
"thread_local",
"struct", "struct",
"union", "union",
"enum", "enum",
@ -308,7 +309,6 @@ tqual_name(tqual_t qual)
"const", "const",
"volatile", "volatile",
"restrict", "restrict",
"_Thread_local",
"_Atomic", "_Atomic",
}; };

View File

@ -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. * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
@ -38,7 +38,7 @@
#include <sys/cdefs.h> #include <sys/cdefs.h>
#if defined(__RCSID) #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 #endif
#include <sys/param.h> #include <sys/param.h>
@ -515,7 +515,7 @@ dcs_add_qualifier(tqual_t q)
} }
dcs->d_volatile = true; dcs->d_volatile = true;
} else { } else {
lint_assert(q == RESTRICT || q == THREAD || q == ATOMIC); lint_assert(q == RESTRICT || q == ATOMIC);
/* Silently ignore these qualifiers. */ /* Silently ignore these qualifiers. */
} }
} }
@ -1448,10 +1448,7 @@ check_function_definition(sym_t *sym, bool msg)
} }
} }
/* /* The symbol gets a storage class and a definedness. */
* 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'.
*/
sym_t * sym_t *
declarator_name(sym_t *sym) declarator_name(sym_t *sym)
{ {
@ -1476,13 +1473,13 @@ declarator_name(sym_t *sym)
break; break;
case DLK_EXTERN: case DLK_EXTERN:
/* /*
* static and external symbols without "extern" are considered * Symbols that are 'static' or without any storage class are
* to be tentatively defined, external symbols with "extern" * tentatively defined. Symbols that are tentatively defined or
* are declared, and typedef names are defined. Tentatively * declared may later become defined if an initializer is seen
* defined and declared symbols may become defined if an * or this is a function definition.
* initializer is present or this is a function definition.
*/ */
if ((sc = dcs->d_scl) == NOSCL) { sc = dcs->d_scl;
if (sc == NOSCL || sc == THREAD_LOCAL) {
sc = EXTERN; sc = EXTERN;
sym->s_def = TDEF; sym->s_def = TDEF;
} else if (sc == STATIC) } else if (sc == STATIC)

View File

@ -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. * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
@ -38,7 +38,7 @@
#include <sys/cdefs.h> #include <sys/cdefs.h>
#if defined(__RCSID) #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 #endif
#include <ctype.h> #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("struct", T_STRUCT_OR_UNION, .u.kw_tspec = STRUCT, 78,0,1),
kwdef_keyword( "switch", T_SWITCH), kwdef_keyword( "switch", T_SWITCH),
kwdef_token( "__symbolrename", T_SYMBOLRENAME, 78,0,1), kwdef_token( "__symbolrename", T_SYMBOLRENAME, 78,0,1),
kwdef_tqual( "__thread", THREAD, 78,1,1), kwdef_sclass( "__thread", THREAD_LOCAL, 78,1,1),
/* XXX: _Thread_local is a storage-class-specifier, not tqual. */ kwdef_sclass( "_Thread_local", THREAD_LOCAL, 11,0,1),
kwdef_tqual( "_Thread_local", THREAD, 11,0,1),
kwdef_sclass( "typedef", TYPEDEF, 78,0,1), kwdef_sclass( "typedef", TYPEDEF, 78,0,1),
kwdef_token( "typeof", T_TYPEOF, 78,1,7), kwdef_token( "typeof", T_TYPEOF, 78,1,7),
#ifdef INT128_SIZE #ifdef INT128_SIZE

View File

@ -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. * 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[] */ void *st_mem; /* char[] for st_char, or wchar_t[] */
} strg_t; } strg_t;
/* /* type qualifiers (only used during parsing) */
* qualifiers (only for lex/yacc interface)
*/
typedef enum { typedef enum {
CONST, CONST,
VOLATILE, VOLATILE,
RESTRICT, RESTRICT,
THREAD, /* XXX: storage-class-qualifier */
ATOMIC, ATOMIC,
} tqual_t; } tqual_t;
@ -198,6 +195,7 @@ typedef enum {
AUTO, /* automatic symbols (except register) */ AUTO, /* automatic symbols (except register) */
REG, /* register */ REG, /* register */
TYPEDEF, /* typedef */ TYPEDEF, /* typedef */
THREAD_LOCAL,
STRUCT_TAG, STRUCT_TAG,
UNION_TAG, UNION_TAG,
ENUM_TAG, ENUM_TAG,