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 GNU __attribute__ a...
details: https://anonhg.NetBSD.org/src/rev/99e398bd2482
branches: trunk
changeset: 1022576:99e398bd2482
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Jul 25 17:40:04 2021 +0000
description:
lint: fix parsing of GNU __attribute__ after __asm
GCC only accepts them in the order __asm __attribute__, not the other
way round. So should lint.
diffstat:
tests/usr.bin/xlint/lint1/parse_init_declarator.c | 6 +---
tests/usr.bin/xlint/lint1/parse_init_declarator.exp | 4 +-
usr.bin/xlint/lint1/cgram.y | 34 ++++++++++++++------
3 files changed, 26 insertions(+), 18 deletions(-)
diffs (115 lines):
diff -r 5c2abee0f253 -r 99e398bd2482 tests/usr.bin/xlint/lint1/parse_init_declarator.c
--- a/tests/usr.bin/xlint/lint1/parse_init_declarator.c Sun Jul 25 17:27:07 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/parse_init_declarator.c Sun Jul 25 17:40:04 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: parse_init_declarator.c,v 1.1 2021/07/25 17:27:07 rillig Exp $ */
+/* $NetBSD: parse_init_declarator.c,v 1.2 2021/07/25 17:40:04 rillig Exp $ */
# 3 "parse_init_declarator.c"
/*
@@ -12,8 +12,6 @@
int *init_declarator_without_initializer
__asm("") __attribute__((deprecated));
-/* expect-1: error: syntax error '__attribute__' [249] */
-/* FIXME */
/* XXX: GCC does not accept this, neither should lint. */
int *init_declarator_without_initializer_wrong_order
@@ -21,8 +19,6 @@
int *init_declarator_with_initializer
__asm("") __attribute__((deprecated)) = &global_var;
-/* expect-1: error: syntax error '__attribute__' [249] */
-/* FIXME */
/* XXX: GCC does not accept this, neither should lint. */
int *init_declarator_with_initializer_wrong_order
diff -r 5c2abee0f253 -r 99e398bd2482 tests/usr.bin/xlint/lint1/parse_init_declarator.exp
--- a/tests/usr.bin/xlint/lint1/parse_init_declarator.exp Sun Jul 25 17:27:07 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/parse_init_declarator.exp Sun Jul 25 17:40:04 2021 +0000
@@ -1,3 +1,1 @@
-parse_init_declarator.c(14): error: syntax error '__attribute__' [249]
-parse_init_declarator.c(23): error: syntax error '__attribute__' [249]
-parse_init_declarator.c(33): error: syntax error '__attribute__' [249]
+parse_init_declarator.c(29): error: syntax error '__attribute__' [249]
diff -r 5c2abee0f253 -r 99e398bd2482 usr.bin/xlint/lint1/cgram.y
--- a/usr.bin/xlint/lint1/cgram.y Sun Jul 25 17:27:07 2021 +0000
+++ b/usr.bin/xlint/lint1/cgram.y Sun Jul 25 17:40:04 2021 +0000
@@ -1,5 +1,5 @@
%{
-/* $NetBSD: cgram.y,v 1.338 2021/07/25 16:57:23 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.339 2021/07/25 17:40:04 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.338 2021/07/25 16:57:23 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.339 2021/07/25 17:40:04 rillig Exp $");
#endif
#include <limits.h>
@@ -124,7 +124,7 @@
%}
-%expect 156
+%expect 159
%union {
val_t *y_val;
@@ -833,11 +833,7 @@
;
type_attribute: /* See C11 6.7 declaration-specifiers */
- T_ATTRIBUTE T_LPAREN T_LPAREN {
- attron = true;
- } gcc_attribute_spec_list {
- attron = false;
- } T_RPAREN T_RPAREN
+ gcc_attribute
/* TODO: c11ism */
| T_ALIGNAS T_LPAREN align_as T_RPAREN
| T_PACKED {
@@ -1592,11 +1588,11 @@
/* empty */ {
$$ = NULL;
}
- | T_ASM T_LPAREN T_STRING T_RPAREN {
+ | T_ASM T_LPAREN T_STRING T_RPAREN gcc_attribute_list_opt {
freeyyv(&$3, T_STRING);
$$ = NULL;
}
- | T_SYMBOLRENAME T_LPAREN T_NAME T_RPAREN {
+ | T_SYMBOLRENAME T_LPAREN T_NAME T_RPAREN gcc_attribute_list_opt {
$$ = $3;
}
;
@@ -2006,6 +2002,24 @@
| begin_type_declaration_specifiers error
;
+gcc_attribute_list_opt:
+ /* empty */
+ | gcc_attribute_list
+ ;
+
+gcc_attribute_list:
+ gcc_attribute
+ | gcc_attribute_list gcc_attribute
+ ;
+
+gcc_attribute:
+ T_ATTRIBUTE T_LPAREN T_LPAREN {
+ attron = true;
+ } gcc_attribute_spec_list {
+ attron = false;
+ } T_RPAREN T_RPAREN
+ ;
+
gcc_attribute_spec_list:
gcc_attribute_spec
| gcc_attribute_spec_list T_COMMA gcc_attribute_spec
Home |
Main Index |
Thread Index |
Old Index