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"
// 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;
}

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.
@ -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",
};

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.
@ -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, bool msg)
}
}
/*
* 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)

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.
@ -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

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.
@ -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,