Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src tests/lint: cover more edge cases in the parser



details:   https://anonhg.NetBSD.org/src/rev/2753390cb261
branches:  trunk
changeset: 1022396:2753390cb261
user:      rillig <rillig%NetBSD.org@localhost>
date:      Thu Jul 15 21:00:05 2021 +0000

description:
tests/lint: cover more edge cases in the parser

diffstat:

 distrib/sets/lists/tests/mi                      |   6 +++++-
 tests/usr.bin/xlint/lint1/Makefile               |   6 +++++-
 tests/usr.bin/xlint/lint1/decl.c                 |   5 ++++-
 tests/usr.bin/xlint/lint1/decl_enum.c            |  19 +++++++++++++++++++
 tests/usr.bin/xlint/lint1/decl_enum.exp          |   3 +++
 tests/usr.bin/xlint/lint1/decl_enum_c90.c        |  13 +++++++++++++
 tests/usr.bin/xlint/lint1/decl_enum_c90.exp      |   1 +
 tests/usr.bin/xlint/lint1/decl_struct_c90.c      |  12 +++++++++++-
 tests/usr.bin/xlint/lint1/decl_struct_c90.exp    |   5 +++--
 tests/usr.bin/xlint/lint1/decl_struct_member.c   |  11 ++++++++++-
 tests/usr.bin/xlint/lint1/decl_struct_member.exp |   4 ++--
 tests/usr.bin/xlint/lint1/gcc_attribute.c        |  12 +++++++++++-
 tests/usr.bin/xlint/lint1/gcc_attribute.exp      |   1 +
 tests/usr.bin/xlint/lint1/gcc_stmt_asm.c         |   6 +++++-
 tests/usr.bin/xlint/lint1/gcc_stmt_asm.exp       |   1 +
 tests/usr.bin/xlint/lint1/msg_343.c              |  10 +++++++++-
 tests/usr.bin/xlint/lint1/msg_343.exp            |   2 ++
 17 files changed, 105 insertions(+), 12 deletions(-)

diffs (261 lines):

diff -r f84f66942e8f -r 2753390cb261 distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi       Thu Jul 15 20:05:49 2021 +0000
+++ b/distrib/sets/lists/tests/mi       Thu Jul 15 21:00:05 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1090 2021/07/15 19:51:29 rillig Exp $
+# $NetBSD: mi,v 1.1091 2021/07/15 21:00:05 rillig Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -6218,6 +6218,10 @@
 ./usr/tests/usr.bin/xlint/lint1/decl.exp                       tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/decl_arg.c                     tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/decl_arg.exp                   tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/decl_enum.c                    tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/decl_enum.exp                  tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/decl_enum_c90.c                        tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/decl_enum_c90.exp              tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/decl_struct_c90.c              tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/decl_struct_c90.exp            tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/decl_struct_member.c           tests-usr.bin-tests     compattestfile,atf
diff -r f84f66942e8f -r 2753390cb261 tests/usr.bin/xlint/lint1/Makefile
--- a/tests/usr.bin/xlint/lint1/Makefile        Thu Jul 15 20:05:49 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/Makefile        Thu Jul 15 21:00:05 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.91 2021/07/15 19:51:29 rillig Exp $
+# $NetBSD: Makefile,v 1.92 2021/07/15 21:00:05 rillig Exp $
 
 NOMAN=         # defined
 MAX_MESSAGE=   345             # see lint1/err.c
@@ -118,6 +118,10 @@
 FILES+=                decl.exp
 FILES+=                decl_arg.c
 FILES+=                decl_arg.exp
+FILES+=                decl_enum.c
+FILES+=                decl_enum.exp
+FILES+=                decl_enum_c90.c
+FILES+=                decl_enum_c90.exp
 FILES+=                decl_struct_c90.c
 FILES+=                decl_struct_c90.exp
 FILES+=                decl_struct_member.c
diff -r f84f66942e8f -r 2753390cb261 tests/usr.bin/xlint/lint1/decl.c
--- a/tests/usr.bin/xlint/lint1/decl.c  Thu Jul 15 20:05:49 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/decl.c  Thu Jul 15 21:00:05 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: decl.c,v 1.5 2021/07/14 20:39:13 rillig Exp $  */
+/*     $NetBSD: decl.c,v 1.6 2021/07/15 21:00:05 rillig Exp $  */
 # 3 "decl.c"
 
 /*
@@ -124,3 +124,6 @@
 unused_linted(void)
 {
 }
+
+/* covers 'type_qualifier_list: type_qualifier_list type_qualifier' */
+int *const volatile cover_type_qualifier_list;
diff -r f84f66942e8f -r 2753390cb261 tests/usr.bin/xlint/lint1/decl_enum.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/decl_enum.c     Thu Jul 15 21:00:05 2021 +0000
@@ -0,0 +1,19 @@
+/*     $NetBSD: decl_enum.c,v 1.1 2021/07/15 21:00:05 rillig Exp $     */
+# 3 "decl_enum.c"
+
+/*
+ * Tests for enum declarations.
+ */
+
+/* cover 'enumerator_list: error' */
+enum {
+       /* expect+1: error: syntax error 'goto' [249] */
+       goto
+};
+
+/* cover 'enum_specifier: enum error' */
+/* expect+1: error: syntax error 'goto' [249] */
+enum goto {
+       A
+};
+/* expect-1: warning: empty declaration [0] */
diff -r f84f66942e8f -r 2753390cb261 tests/usr.bin/xlint/lint1/decl_enum.exp
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/decl_enum.exp   Thu Jul 15 21:00:05 2021 +0000
@@ -0,0 +1,3 @@
+decl_enum.c(11): error: syntax error 'goto' [249]
+decl_enum.c(16): error: syntax error 'goto' [249]
+decl_enum.c(18): warning: empty declaration [0]
diff -r f84f66942e8f -r 2753390cb261 tests/usr.bin/xlint/lint1/decl_enum_c90.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/decl_enum_c90.c Thu Jul 15 21:00:05 2021 +0000
@@ -0,0 +1,13 @@
+/*     $NetBSD: decl_enum_c90.c,v 1.1 2021/07/15 21:00:05 rillig Exp $ */
+# 3 "decl_enum_c90.c"
+
+/*
+ * Tests for enum declarations in C90 mode.
+ */
+
+/* lint1-flags: -sw */
+
+enum {
+       A,
+};
+/* expect-1: trailing ',' prohibited in enum declaration [54] */
diff -r f84f66942e8f -r 2753390cb261 tests/usr.bin/xlint/lint1/decl_enum_c90.exp
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/decl_enum_c90.exp       Thu Jul 15 21:00:05 2021 +0000
@@ -0,0 +1,1 @@
+decl_enum_c90.c(12): error: trailing ',' prohibited in enum declaration [54]
diff -r f84f66942e8f -r 2753390cb261 tests/usr.bin/xlint/lint1/decl_struct_c90.c
--- a/tests/usr.bin/xlint/lint1/decl_struct_c90.c       Thu Jul 15 20:05:49 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/decl_struct_c90.c       Thu Jul 15 21:00:05 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: decl_struct_c90.c,v 1.2 2021/07/15 20:05:49 rillig Exp $       */
+/*     $NetBSD: decl_struct_c90.c,v 1.3 2021/07/15 21:00:05 rillig Exp $       */
 # 3 "decl_struct_c90.c"
 
 /*
@@ -7,6 +7,16 @@
 
 /* lint1-flags: -sw */
 
+struct unnamed_member {
+       enum { A, B, C } tag;
+       union {
+               int a_value;
+               void *b_value;
+               void (*c_value)(void);
+       };
+       /* expect-1: warning: anonymous struct/union members is a C9X feature [49] */
+};
+
 /*
  * All of K&R, C90, C99 require that a struct member declaration is
  * terminated with a semicolon.
diff -r f84f66942e8f -r 2753390cb261 tests/usr.bin/xlint/lint1/decl_struct_c90.exp
--- a/tests/usr.bin/xlint/lint1/decl_struct_c90.exp     Thu Jul 15 20:05:49 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/decl_struct_c90.exp     Thu Jul 15 21:00:05 2021 +0000
@@ -1,2 +1,3 @@
-decl_struct_c90.c(19): error: syntax error '}' [249]
-decl_struct_c90.c(22): error: cannot recover from previous errors [224]
+decl_struct_c90.c(16): warning: anonymous struct/union members is a C9X feature [49]
+decl_struct_c90.c(29): error: syntax error '}' [249]
+decl_struct_c90.c(32): error: cannot recover from previous errors [224]
diff -r f84f66942e8f -r 2753390cb261 tests/usr.bin/xlint/lint1/decl_struct_member.c
--- a/tests/usr.bin/xlint/lint1/decl_struct_member.c    Thu Jul 15 20:05:49 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/decl_struct_member.c    Thu Jul 15 21:00:05 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: decl_struct_member.c,v 1.8 2021/07/15 20:05:49 rillig Exp $    */
+/*     $NetBSD: decl_struct_member.c,v 1.9 2021/07/15 21:00:05 rillig Exp $    */
 # 3 "decl_struct_member.c"
 
 struct multi_attributes {
@@ -47,6 +47,15 @@
        char;                   /* expect: syntax error 'unnamed member' */
 };
 
+struct cover_notype_struct_declarators {
+       const a, b;
+};
+
+struct cover_notype_struct_declarator_bit_field {
+       const a: 3, : 0, b: 4;
+       const : 0;
+};
+
 /*
  * Before decl.c 1.188 from 2021-06-20, lint ran into a segmentation fault.
  */
diff -r f84f66942e8f -r 2753390cb261 tests/usr.bin/xlint/lint1/decl_struct_member.exp
--- a/tests/usr.bin/xlint/lint1/decl_struct_member.exp  Thu Jul 15 20:05:49 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/decl_struct_member.exp  Thu Jul 15 21:00:05 2021 +0000
@@ -3,5 +3,5 @@
 decl_struct_member.c(38): error: syntax error '}' [249]
 decl_struct_member.c(38): warning: empty declaration [0]
 decl_struct_member.c(47): error: syntax error 'unnamed member' [249]
-decl_struct_member.c(54): error: syntax error '0' [249]
-decl_struct_member.c(62): error: cannot recover from previous errors [224]
+decl_struct_member.c(63): error: syntax error '0' [249]
+decl_struct_member.c(71): error: cannot recover from previous errors [224]
diff -r f84f66942e8f -r 2753390cb261 tests/usr.bin/xlint/lint1/gcc_attribute.c
--- a/tests/usr.bin/xlint/lint1/gcc_attribute.c Thu Jul 15 20:05:49 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/gcc_attribute.c Thu Jul 15 21:00:05 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: gcc_attribute.c,v 1.9 2021/07/09 18:55:28 rillig Exp $ */
+/*     $NetBSD: gcc_attribute.c,v 1.10 2021/07/15 21:00:05 rillig Exp $        */
 # 3 "gcc_attribute.c"
 
 /*
@@ -117,3 +117,13 @@
     )
     __attribute__((deprecated("d8")))
 ;
+
+/*
+ * The attribute 'const' provides stronger guarantees than 'pure', and
+ * 'volatile' is not defined.  To keep the grammar simple, any T_QUAL is
+ * allowed at this point, but only syntactically.
+ */
+int const_function(int) __attribute__((const));
+/* cover 'gcc_attribute_spec: T_QUAL' */
+/* expect+1: syntax error 'volatile' [249] */
+int volatile_function(int) __attribute__((volatile));
diff -r f84f66942e8f -r 2753390cb261 tests/usr.bin/xlint/lint1/gcc_attribute.exp
--- a/tests/usr.bin/xlint/lint1/gcc_attribute.exp       Thu Jul 15 20:05:49 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/gcc_attribute.exp       Thu Jul 15 21:00:05 2021 +0000
@@ -1,1 +1,2 @@
 gcc_attribute.c(33): error: syntax error 'unknown_attribute' [249]
+gcc_attribute.c(129): error: syntax error 'volatile' [249]
diff -r f84f66942e8f -r 2753390cb261 tests/usr.bin/xlint/lint1/gcc_stmt_asm.c
--- a/tests/usr.bin/xlint/lint1/gcc_stmt_asm.c  Thu Jul 15 20:05:49 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/gcc_stmt_asm.c  Thu Jul 15 21:00:05 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: gcc_stmt_asm.c,v 1.1 2021/07/14 20:39:13 rillig Exp $  */
+/*     $NetBSD: gcc_stmt_asm.c,v 1.2 2021/07/15 21:00:05 rillig Exp $  */
 # 3 "gcc_stmt_asm.c"
 
 /*
@@ -36,3 +36,7 @@
        /* expect+1: syntax error '__asm__' [249] */
        int i = __asm__();
 }
+
+__asm__(
+/* cover ignore_up_to_rparen at EOF */
+/* expect+1: error: syntax error '' [249] */
diff -r f84f66942e8f -r 2753390cb261 tests/usr.bin/xlint/lint1/gcc_stmt_asm.exp
--- a/tests/usr.bin/xlint/lint1/gcc_stmt_asm.exp        Thu Jul 15 20:05:49 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/gcc_stmt_asm.exp        Thu Jul 15 21:00:05 2021 +0000
@@ -1,1 +1,2 @@
 gcc_stmt_asm.c(37): error: syntax error '__asm__' [249]
+gcc_stmt_asm.c(43): error: syntax error '' [249]
diff -r f84f66942e8f -r 2753390cb261 tests/usr.bin/xlint/lint1/msg_343.c
--- a/tests/usr.bin/xlint/lint1/msg_343.c       Thu Jul 15 20:05:49 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_343.c       Thu Jul 15 21:00:05 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: msg_343.c,v 1.4 2021/04/14 22:06:38 rillig Exp $       */
+/*     $NetBSD: msg_343.c,v 1.5 2021/07/15 21:00:05 rillig Exp $       */
 # 3 "msg_343.c"
 
 /* Test for message: static array size is a C11 extension [343] */
@@ -37,3 +37,11 @@
        /* expect+1: expects to return value */
        return a[0];
 }
+
+/*
+ * This triggers the "Bad attribute", but for some reason, that custom error
+ * message does not make it into the actual diagnostic.
+ */
+/* expect+2: error: syntax error ']' [249] */
+/* expect+1: error: static array size is a C11 extension [343] */
+void invalid_storage_class(int a[const typedef 3]);
diff -r f84f66942e8f -r 2753390cb261 tests/usr.bin/xlint/lint1/msg_343.exp
--- a/tests/usr.bin/xlint/lint1/msg_343.exp     Thu Jul 15 20:05:49 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_343.exp     Thu Jul 15 21:00:05 2021 +0000
@@ -4,3 +4,5 @@
 msg_343.c(34): error: syntax error '3' [249]
 msg_343.c(38): error: cannot dereference non-pointer type [96]
 msg_343.c(38): warning: function returns_volatile_int_array expects to return value [214]
+msg_343.c(47): error: syntax error ']' [249]
+msg_343.c(47): error: static array size is a C11 extension [343]



Home | Main Index | Thread Index | Old Index