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: _Thread_local is a storage class, ...



details:   https://anonhg.NetBSD.org/src/rev/7d478d8952cd
branches:  trunk
changeset: 377474:7d478d8952cd
user:      rillig <rillig%NetBSD.org@localhost>
date:      Thu Jul 13 19:59:08 2023 +0000

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

diffstat:

 tests/usr.bin/xlint/lint1/msg_010.c |   5 +++--
 usr.bin/xlint/lint1/debug.c         |   6 +++---
 usr.bin/xlint/lint1/decl.c          |  23 ++++++++++-------------
 usr.bin/xlint/lint1/lex.c           |   9 ++++-----
 usr.bin/xlint/lint1/lint1.h         |   8 +++-----
 5 files changed, 23 insertions(+), 28 deletions(-)

diffs (176 lines):

diff -r b8f2a38d734e -r 7d478d8952cd tests/usr.bin/xlint/lint1/msg_010.c
--- a/tests/usr.bin/xlint/lint1/msg_010.c       Thu Jul 13 19:42:24 2023 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_010.c       Thu Jul 13 19:59:08 2023 +0000
@@ -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;
 }
diff -r b8f2a38d734e -r 7d478d8952cd usr.bin/xlint/lint1/debug.c
--- a/usr.bin/xlint/lint1/debug.c       Thu Jul 13 19:42:24 2023 +0000
+++ b/usr.bin/xlint/lint1/debug.c       Thu Jul 13 19:59:08 2023 +0000
@@ -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",
        };
 
diff -r b8f2a38d734e -r 7d478d8952cd usr.bin/xlint/lint1/decl.c
--- a/usr.bin/xlint/lint1/decl.c        Thu Jul 13 19:42:24 2023 +0000
+++ b/usr.bin/xlint/lint1/decl.c        Thu Jul 13 19:59:08 2023 +0000
@@ -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)
diff -r b8f2a38d734e -r 7d478d8952cd usr.bin/xlint/lint1/lex.c
--- a/usr.bin/xlint/lint1/lex.c Thu Jul 13 19:42:24 2023 +0000
+++ b/usr.bin/xlint/lint1/lex.c Thu Jul 13 19:59:08 2023 +0000
@@ -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
diff -r b8f2a38d734e -r 7d478d8952cd usr.bin/xlint/lint1/lint1.h
--- a/usr.bin/xlint/lint1/lint1.h       Thu Jul 13 19:42:24 2023 +0000
+++ b/usr.bin/xlint/lint1/lint1.h       Thu Jul 13 19:59:08 2023 +0000
@@ -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,



Home | Main Index | Thread Index | Old Index