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: support all documented variants of...



details:   https://anonhg.NetBSD.org/src/rev/b39d6b3431ed
branches:  trunk
changeset: 378959:b39d6b3431ed
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat May 01 07:25:07 2021 +0000

description:
lint: support all documented variants of __attribute__((nonnull))

diffstat:

 tests/usr.bin/xlint/lint1/gcc_attribute.c   |  10 +++++++---
 tests/usr.bin/xlint/lint1/gcc_attribute.exp |   3 +--
 usr.bin/xlint/lint1/cgram.y                 |  17 ++++++++++++++---
 3 files changed, 22 insertions(+), 8 deletions(-)

diffs (78 lines):

diff -r 8b575f947748 -r b39d6b3431ed tests/usr.bin/xlint/lint1/gcc_attribute.c
--- a/tests/usr.bin/xlint/lint1/gcc_attribute.c Sat May 01 07:13:21 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/gcc_attribute.c Sat May 01 07:25:07 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: gcc_attribute.c,v 1.1 2021/04/30 23:49:36 rillig Exp $ */
+/*     $NetBSD: gcc_attribute.c,v 1.2 2021/05/01 07:25:07 rillig Exp $ */
 # 3 "gcc_attribute.c"
 
 /*
@@ -19,9 +19,13 @@ do_not_inline(void)
 {
 }
 
-/* expect+1: syntax error 'nonnull' */
+/* All pointer arguments must be nonnull. */
+void __attribute__((nonnull))
+function_nonnull(void *, const void *, int);
+
+/* Arguments 1 and 2 must be nonnull. */
 void __attribute__((nonnull(1, 2)))
-my_memcpy(void *dest, const void *src, unsigned long len);
+function_nonnull_list(void *, const void *, int);
 
 /* expect+1: syntax error 'unknown_attribute' */
 void __attribute__((unknown_attribute))
diff -r 8b575f947748 -r b39d6b3431ed tests/usr.bin/xlint/lint1/gcc_attribute.exp
--- a/tests/usr.bin/xlint/lint1/gcc_attribute.exp       Sat May 01 07:13:21 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/gcc_attribute.exp       Sat May 01 07:25:07 2021 +0000
@@ -1,2 +1,1 @@
-gcc_attribute.c(23): error: syntax error 'nonnull' [249]
-gcc_attribute.c(27): error: syntax error 'unknown_attribute' [249]
+gcc_attribute.c(31): error: syntax error 'unknown_attribute' [249]
diff -r 8b575f947748 -r b39d6b3431ed usr.bin/xlint/lint1/cgram.y
--- a/usr.bin/xlint/lint1/cgram.y       Sat May 01 07:13:21 2021 +0000
+++ b/usr.bin/xlint/lint1/cgram.y       Sat May 01 07:25:07 2021 +0000
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: cgram.y,v 1.223 2021/04/30 19:46:24 christos Exp $ */
+/* $NetBSD: cgram.y,v 1.224 2021/05/01 07:25:07 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.223 2021/04/30 19:46:24 christos Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.224 2021/05/01 07:25:07 rillig Exp $");
 #endif
 
 #include <limits.h>
@@ -563,7 +563,8 @@ type_attribute_spec:
        | T_AT_SENTINEL T_LPAREN constant_expr T_RPAREN
        | T_AT_SENTINEL
        | T_AT_FORMAT_ARG T_LPAREN constant_expr T_RPAREN
-       | T_AT_NONNULL T_LPAREN constant_expr T_RPAREN
+       | T_AT_NONNULL
+       | T_AT_NONNULL T_LPAREN constant_expr_list_opt T_RPAREN
        | T_AT_NONSTRING
        | T_AT_MODE T_LPAREN T_NAME T_RPAREN
        | T_AT_ALIAS T_LPAREN string T_RPAREN
@@ -1844,6 +1845,16 @@ declaration_list:
          }
        ;
 
+constant_expr_list_opt:
+         /* empty */
+       | constant_expr_list
+       ;
+
+constant_expr_list:
+         constant_expr
+       | constant_expr_list T_COMMA constant_expr
+       ;
+
 constant_expr:                 /* C99 6.6 */
          expr                          %prec T_ASSIGN {
                  $$ = $1;



Home | Main Index | Thread Index | Old Index