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 parsing of 'typeof(double(type...
details: https://anonhg.NetBSD.org/src/rev/3c66a8ff1120
branches: trunk
changeset: 1022571:3c66a8ff1120
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Jul 25 15:48:57 2021 +0000
description:
lint: fix parsing of 'typeof(double(typeof(0.0)))'
By removing the misplaced grammar rule 'abstract_declarator: T_TYPEOF',
the type expression 'typeof(double(typeof(0.0)))' is no longer
interpreted as a declarator, but rather as a type specifier, just as in
the GCC parser.
This resolves 7 shift/reduce conflicts.
diffstat:
tests/usr.bin/xlint/lint1/parse_type_name.c | 3 ++-
tests/usr.bin/xlint/lint1/parse_type_name.exp | 13 +++++++------
usr.bin/xlint/lint1/cgram.y | 9 +++------
3 files changed, 12 insertions(+), 13 deletions(-)
diffs (72 lines):
diff -r 48c97caf6ea3 -r 3c66a8ff1120 tests/usr.bin/xlint/lint1/parse_type_name.c
--- a/tests/usr.bin/xlint/lint1/parse_type_name.c Sun Jul 25 11:19:51 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/parse_type_name.c Sun Jul 25 15:48:57 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: parse_type_name.c,v 1.3 2021/07/25 09:53:01 rillig Exp $ */
+/* $NetBSD: parse_type_name.c,v 1.4 2021/07/25 15:48:58 rillig Exp $ */
# 3 "parse_type_name.c"
/*
@@ -48,6 +48,7 @@
sink(sizeof(int **[3]));
/* cover 'T_TYPEOF cast_expression' */
+ /* expect+1: error: cannot take size/alignment of function [144] */
sink(sizeof(int(typeof(12345))));
}
diff -r 48c97caf6ea3 -r 3c66a8ff1120 tests/usr.bin/xlint/lint1/parse_type_name.exp
--- a/tests/usr.bin/xlint/lint1/parse_type_name.exp Sun Jul 25 11:19:51 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/parse_type_name.exp Sun Jul 25 15:48:57 2021 +0000
@@ -1,6 +1,7 @@
-parse_type_name.c(71): error: null dimension [17]
-parse_type_name.c(75): error: null dimension [17]
-parse_type_name.c(141): error: syntax error 'goto' [249]
-parse_type_name.c(143): error: syntax error 'goto' [249]
-parse_type_name.c(149): error: syntax error 'goto' [249]
-parse_type_name.c(163): warning: ANSI C requires formal parameter before '...' [84]
+parse_type_name.c(52): error: cannot take size/alignment of function [144]
+parse_type_name.c(72): error: null dimension [17]
+parse_type_name.c(76): error: null dimension [17]
+parse_type_name.c(142): error: syntax error 'goto' [249]
+parse_type_name.c(144): error: syntax error 'goto' [249]
+parse_type_name.c(150): error: syntax error 'goto' [249]
+parse_type_name.c(164): warning: ANSI C requires formal parameter before '...' [84]
diff -r 48c97caf6ea3 -r 3c66a8ff1120 usr.bin/xlint/lint1/cgram.y
--- a/usr.bin/xlint/lint1/cgram.y Sun Jul 25 11:19:51 2021 +0000
+++ b/usr.bin/xlint/lint1/cgram.y Sun Jul 25 15:48:57 2021 +0000
@@ -1,5 +1,5 @@
%{
-/* $NetBSD: cgram.y,v 1.335 2021/07/23 15:14:49 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.336 2021/07/25 15:48:57 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.335 2021/07/23 15:14:49 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.336 2021/07/25 15:48:57 rillig Exp $");
#endif
#include <limits.h>
@@ -124,7 +124,7 @@
%}
-%expect 165
+%expect 158
%union {
val_t *y_val;
@@ -1390,9 +1390,6 @@
| pointer direct_abstract_declarator {
$$ = add_pointer($2, $1);
}
- | T_TYPEOF cast_expression { /* GCC extension */
- $$ = mktempsym($2->tn_type);
- }
;
direct_abstract_declarator: /* C99 6.7.6 */
Home |
Main Index |
Thread Index |
Old Index