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: allow GCC __attribute__ after arra...



details:   https://anonhg.NetBSD.org/src/rev/174256a253fe
branches:  trunk
changeset: 1022880:174256a253fe
user:      rillig <rillig%NetBSD.org@localhost>
date:      Wed Aug 11 05:19:32 2021 +0000

description:
lint: allow GCC __attribute__ after array brackets

GCC accepts this, so should lint.  Seen in pam_lastlog.c:115.

diffstat:

 tests/usr.bin/xlint/lint1/gcc_attribute_var.c   |  4 +---
 tests/usr.bin/xlint/lint1/gcc_attribute_var.exp |  3 +--
 usr.bin/xlint/lint1/cgram.y                     |  9 +++++----
 3 files changed, 7 insertions(+), 9 deletions(-)

diffs (59 lines):

diff -r fd6e77c7e233 -r 174256a253fe tests/usr.bin/xlint/lint1/gcc_attribute_var.c
--- a/tests/usr.bin/xlint/lint1/gcc_attribute_var.c     Wed Aug 11 05:17:48 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/gcc_attribute_var.c     Wed Aug 11 05:19:32 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: gcc_attribute_var.c,v 1.4 2021/08/11 05:08:35 rillig Exp $     */
+/*     $NetBSD: gcc_attribute_var.c,v 1.5 2021/08/11 05:19:33 rillig Exp $     */
 # 3 "gcc_attribute_var.c"
 
 /*
@@ -65,8 +65,6 @@
 
 void
 attribute_after_array_brackets(
-    /* FIXME: GCC accepts this */
-    /* expect+1: error: syntax error '__attribute__' [249] */
     const char *argv[] __attribute__((__unused__))
 )
 {
diff -r fd6e77c7e233 -r 174256a253fe tests/usr.bin/xlint/lint1/gcc_attribute_var.exp
--- a/tests/usr.bin/xlint/lint1/gcc_attribute_var.exp   Wed Aug 11 05:17:48 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/gcc_attribute_var.exp   Wed Aug 11 05:19:32 2021 +0000
@@ -1,3 +1,2 @@
 gcc_attribute_var.c(59): warning: 'var2' unused in function 'ambiguity_for_attribute' [192]
-gcc_attribute_var.c(70): error: syntax error '__attribute__' [249]
-gcc_attribute_var.c(77): error: syntax error 'syntax_error' [249]
+gcc_attribute_var.c(75): error: syntax error 'syntax_error' [249]
diff -r fd6e77c7e233 -r 174256a253fe usr.bin/xlint/lint1/cgram.y
--- a/usr.bin/xlint/lint1/cgram.y       Wed Aug 11 05:17:48 2021 +0000
+++ b/usr.bin/xlint/lint1/cgram.y       Wed Aug 11 05:19:32 2021 +0000
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: cgram.y,v 1.354 2021/08/01 19:18:10 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.355 2021/08/11 05:19:32 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.354 2021/08/01 19:18:10 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.355 2021/08/11 05:19:32 rillig Exp $");
 #endif
 
 #include <limits.h>
@@ -1292,10 +1292,11 @@
        | T_LPAREN notype_param_declarator T_RPAREN {
                $$ = $2;
          }
-       | direct_param_declarator T_LBRACK T_RBRACK {
+       | direct_param_declarator T_LBRACK T_RBRACK gcc_attribute_list_opt {
                $$ = add_array($1, false, 0);
          }
-       | direct_param_declarator T_LBRACK array_size T_RBRACK {
+       | direct_param_declarator T_LBRACK array_size T_RBRACK
+           gcc_attribute_list_opt {
                $$ = add_array($1, true, to_int_constant($3, false));
          }
        | direct_param_declarator param_list asm_or_symbolrename_opt {



Home | Main Index | Thread Index | Old Index