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: fix assertion failure on duplicate...
details: https://anonhg.NetBSD.org/src/rev/2c953ea62cef
branches: trunk
changeset: 365184:2c953ea62cef
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Apr 10 12:14:10 2022 +0000
description:
lint: fix assertion failure on duplicate qualifiers from __typeof__
diffstat:
tests/usr.bin/xlint/lint1/gcc_typeof.c | 12 +++++++++++-
usr.bin/xlint/lint1/cgram.y | 7 ++++---
usr.bin/xlint/lint1/decl.c | 9 +++++----
usr.bin/xlint/lint1/lint1.h | 3 ++-
4 files changed, 22 insertions(+), 9 deletions(-)
diffs (103 lines):
diff -r e422b28d83f2 -r 2c953ea62cef tests/usr.bin/xlint/lint1/gcc_typeof.c
--- a/tests/usr.bin/xlint/lint1/gcc_typeof.c Sun Apr 10 11:56:28 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/gcc_typeof.c Sun Apr 10 12:14:10 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: gcc_typeof.c,v 1.3 2021/07/25 15:58:24 rillig Exp $ */
+/* $NetBSD: gcc_typeof.c,v 1.4 2022/04/10 12:14:10 rillig Exp $ */
# 3 "gcc_typeof.c"
/*
@@ -31,3 +31,13 @@
/* identity cast */
take_function_double_returning_double((double (*)(double))fn);
}
+
+/*
+ * Since cgram 1.58 from 2014-02-18, when support for __typeof__ was added,
+ * and before cgram.y 1.394 from 2022-04-10, lint ran into an assertion
+ * failure when encountering a redundant type qualifier 'const' or 'volatile'
+ * in a declaration using __typeof__. Seen in sys/sys/lwp.h on x86_64, in
+ * the call atomic_load_consume(&l->l_mutex).
+ */
+int *volatile lock;
+const volatile __typeof__(lock) *lock_pointer = &lock;
diff -r e422b28d83f2 -r 2c953ea62cef usr.bin/xlint/lint1/cgram.y
--- a/usr.bin/xlint/lint1/cgram.y Sun Apr 10 11:56:28 2022 +0000
+++ b/usr.bin/xlint/lint1/cgram.y Sun Apr 10 12:14:10 2022 +0000
@@ -1,5 +1,5 @@
%{
-/* $NetBSD: cgram.y,v 1.393 2022/04/09 23:41:22 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.394 2022/04/10 12:14:10 rillig Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
@@ -35,7 +35,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: cgram.y,v 1.393 2022/04/09 23:41:22 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.394 2022/04/10 12:14:10 rillig Exp $");
#endif
#include <limits.h>
@@ -878,7 +878,8 @@
$$ = gettyp($1);
}
| T_TYPEOF T_LPAREN expression T_RPAREN { /* GCC extension */
- $$ = $3->tn_type;
+ $$ = block_dup_type($3->tn_type);
+ $$->t_typeof = true;
}
| struct_or_union_specifier {
end_declaration_level();
diff -r e422b28d83f2 -r 2c953ea62cef usr.bin/xlint/lint1/decl.c
--- a/usr.bin/xlint/lint1/decl.c Sun Apr 10 11:56:28 2022 +0000
+++ b/usr.bin/xlint/lint1/decl.c Sun Apr 10 12:14:10 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.276 2022/04/09 23:41:22 rillig Exp $ */
+/* $NetBSD: decl.c,v 1.277 2022/04/10 12:14:10 rillig Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
@@ -38,7 +38,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: decl.c,v 1.276 2022/04/09 23:41:22 rillig Exp $");
+__RCSID("$NetBSD: decl.c,v 1.277 2022/04/10 12:14:10 rillig Exp $");
#endif
#include <sys/param.h>
@@ -815,12 +815,13 @@
dcs_adjust_storage_class();
- if (dcs->d_const && dcs->d_type->t_const) {
+ if (dcs->d_const && dcs->d_type->t_const && !dcs->d_type->t_typeof) {
lint_assert(dcs->d_type->t_typedef);
/* typedef already qualified with '%s' */
warning(68, "const");
}
- if (dcs->d_volatile && dcs->d_type->t_volatile) {
+ if (dcs->d_volatile && dcs->d_type->t_volatile &&
+ !dcs->d_type->t_typeof) {
lint_assert(dcs->d_type->t_typedef);
/* typedef already qualified with '%s' */
warning(68, "volatile");
diff -r e422b28d83f2 -r 2c953ea62cef usr.bin/xlint/lint1/lint1.h
--- a/usr.bin/xlint/lint1/lint1.h Sun Apr 10 11:56:28 2022 +0000
+++ b/usr.bin/xlint/lint1/lint1.h Sun Apr 10 12:14:10 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lint1.h,v 1.150 2022/04/09 23:41:22 rillig Exp $ */
+/* $NetBSD: lint1.h,v 1.151 2022/04/10 12:14:10 rillig Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
@@ -143,6 +143,7 @@
bool t_proto:1; /* function prototype (t_args valid) */
bool t_vararg:1; /* prototype with '...' */
bool t_typedef:1; /* type defined with typedef */
+ bool t_typeof:1; /* type defined with GCC's __typeof__ */
bool t_bitfield:1;
/*
* Either the type is currently an enum (having t_tspec ENUM), or
Home |
Main Index |
Thread Index |
Old Index