Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src tests/lint: test parsing of type_name
details: https://anonhg.NetBSD.org/src/rev/6e053b27e668
branches: trunk
changeset: 984830:6e053b27e668
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Jul 25 08:42:28 2021 +0000
description:
tests/lint: test parsing of type_name
diffstat:
distrib/sets/lists/tests/mi | 4 +-
tests/usr.bin/xlint/lint1/Makefile | 4 +-
tests/usr.bin/xlint/lint1/decl.c | 9 +-
tests/usr.bin/xlint/lint1/decl.exp | 4 +-
tests/usr.bin/xlint/lint1/parse_type_name.c | 200 ++++++++++++++++++++++++++
tests/usr.bin/xlint/lint1/parse_type_name.exp | 6 +
6 files changed, 215 insertions(+), 12 deletions(-)
diffs (285 lines):
diff -r 575907741ac0 -r 6e053b27e668 distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi Sun Jul 25 07:35:55 2021 +0000
+++ b/distrib/sets/lists/tests/mi Sun Jul 25 08:42:28 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1091 2021/07/15 21:00:05 rillig Exp $
+# $NetBSD: mi,v 1.1092 2021/07/25 08:42:28 rillig Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@@ -6990,6 +6990,8 @@
./usr/tests/usr.bin/xlint/lint1/op_colon.exp tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/op_shl_lp64.c tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/op_shl_lp64.exp tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/parse_type_name.c tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/parse_type_name.exp tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/stmt_for.c tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/stmt_for.exp tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/stmt_goto.c tests-usr.bin-tests compattestfile,atf
diff -r 575907741ac0 -r 6e053b27e668 tests/usr.bin/xlint/lint1/Makefile
--- a/tests/usr.bin/xlint/lint1/Makefile Sun Jul 25 07:35:55 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/Makefile Sun Jul 25 08:42:28 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.92 2021/07/15 21:00:05 rillig Exp $
+# $NetBSD: Makefile,v 1.93 2021/07/25 08:42:28 rillig Exp $
NOMAN= # defined
MAX_MESSAGE= 345 # see lint1/err.c
@@ -196,6 +196,8 @@
FILES+= op_colon.exp
FILES+= op_shl_lp64.c
FILES+= op_shl_lp64.exp
+FILES+= parse_type_name.c
+FILES+= parse_type_name.exp
FILES+= stmt_for.c
FILES+= stmt_for.exp
FILES+= stmt_goto.c
diff -r 575907741ac0 -r 6e053b27e668 tests/usr.bin/xlint/lint1/decl.c
--- a/tests/usr.bin/xlint/lint1/decl.c Sun Jul 25 07:35:55 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/decl.c Sun Jul 25 08:42:28 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.10 2021/07/23 15:21:47 rillig Exp $ */
+/* $NetBSD: decl.c,v 1.11 2021/07/25 08:42:28 rillig Exp $ */
# 3 "decl.c"
/*
@@ -128,13 +128,6 @@
/* covers 'type_qualifier_list: type_qualifier_list type_qualifier' */
int *const volatile cover_type_qualifier_list;
-unsigned long cover_abstract_declaration_declmods = sizeof(const);
-unsigned long cover_abstract_declaration_declmods_abstract_declarator =
- sizeof(const *);
-
-unsigned long cover_abstract_declarator_typeof =
- sizeof(const typeof(cover_abstract_declaration_declmods));
-
_Bool bool;
char plain_char;
signed char signed_char;
diff -r 575907741ac0 -r 6e053b27e668 tests/usr.bin/xlint/lint1/decl.exp
--- a/tests/usr.bin/xlint/lint1/decl.exp Sun Jul 25 07:35:55 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/decl.exp Sun Jul 25 08:42:28 2021 +0000
@@ -9,6 +9,6 @@
decl.c(70): warning: illegal combination of pointer (pointer to double) and integer (char), arg #1 [154]
decl.c(72): warning: converting 'pointer to pointer to char' to incompatible 'pointer to double' for argument 1 [153]
decl.c(80): error: syntax error '"' [249]
-decl.c(170): error: syntax error 'int' [249]
-decl.c(173): error: syntax error 'int' [249]
+decl.c(163): error: syntax error 'int' [249]
+decl.c(166): error: syntax error 'int' [249]
decl.c(114): warning: static function unused unused [236]
diff -r 575907741ac0 -r 6e053b27e668 tests/usr.bin/xlint/lint1/parse_type_name.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/parse_type_name.c Sun Jul 25 08:42:28 2021 +0000
@@ -0,0 +1,200 @@
+/* $NetBSD: parse_type_name.c,v 1.1 2021/07/25 08:42:28 rillig Exp $ */
+# 3 "parse_type_name.c"
+
+/*
+ * Test parsing of the grammar rule 'type_name', which among others appears
+ * in the expression 'sizeof(type_name)'.
+ */
+
+void sink(unsigned long);
+
+void
+cover_type_name(void)
+{
+ /* cover 'abstract_declaration' */
+ sink(sizeof(int));
+}
+
+void
+cover_abstract_declaration(void)
+{
+ /* cover 'qualifier_list' */
+ /* missing type-specifier, even in traditional C */
+ /* lint doesn't care since this is caught by the compiler */
+ sink(sizeof(const));
+
+ /* cover 'specifier_qualifier_list' */
+ sink(sizeof(double));
+
+ /* cover 'qualifier_list abstract_declarator' */
+ /* XXX: This is nonsense, lint should not accept it. */
+ sink(sizeof(const[3]));
+
+ /* cover 'specifier_qualifier_list abstract_declarator' */
+ sink(sizeof(const int[3]));
+ sink(sizeof(int const[3]));
+}
+
+void
+cover_abstract_declarator(void)
+{
+ /* cover 'pointer' */
+ sink(sizeof(int ***));
+
+ /* cover 'direct_abstract_declarator' */
+ sink(sizeof(int[3]));
+
+ /* cover 'pointer direct_abstract_declarator' */
+ sink(sizeof(int **[3]));
+
+ /* cover 'T_TYPEOF cast_expression' */
+ /* TODO */
+}
+
+void
+cover_direct_abstract_declarator(void)
+{
+ /* cover 'T_LPAREN abstract_declarator T_RPAREN' */
+ sink(sizeof(int (*)));
+
+ /* cover 'T_LBRACK T_RBRACK' */
+ sink(sizeof(int[]));
+
+ /* cover 'T_LBRACK array_size T_RBRACK' */
+ sink(sizeof(int[3]));
+
+ /* cover 'type_attribute direct_abstract_declarator' */
+ /* TODO */
+
+ /* cover 'direct_abstract_declarator T_LBRACK T_RBRACK' */
+ /* expect+1: error: null dimension [17] */
+ sink(sizeof(int[3][]));
+
+ /* cover 'direct_abstract_declarator T_LBRACK T_ASTERISK T_RBRACK' */
+ /* expect+1: error: null dimension [17] */
+ sink(sizeof(int[3][ *]));
+
+ /* cover 'direct_abstract_declarator T_LBRACK array_size T_RBRACK' */
+ sink(sizeof(int[3][5][8]));
+
+ /* cover 'abstract_decl_param_list asm_or_symbolrename_opt' */
+ sink(sizeof(int(double)));
+ sink(sizeof(
+ int(
+ double) __asm("anything")));
+ sink(sizeof(
+ int(
+ double) __symbolrename(alias)));
+
+ /* cover 'direct_abstract_declarator abstract_decl_param_list asm_or_symbolrename_opt' */
+ sink(sizeof(int (*)(double)));
+ sink(sizeof(
+ int(*)(double) __asm("anything")));
+ sink(sizeof(
+ int(*)
+ (double)__symbolrename(alias)));
+
+ /* cover 'direct_abstract_declarator type_attribute_list' */
+ sink(sizeof(
+ int(*)
+ __attribute__(())));
+ sink(sizeof(
+ int(*)
+ __attribute__(())
+ __attribute__(())));
+}
+
+void
+cover_abstract_decl_param_list(void)
+{
+ /* cover 'abstract_decl_lparen T_RPAREN type_attribute_opt' */
+ sink(sizeof(void (*)()));
+ sink(sizeof(
+ void (*)
+ ()
+ __attribute__(())));
+ /*
+ * XXX: The grammar allows only a single type_attribute_opt.
+ * Where does the second type_attribute go?
+ */
+ sink(sizeof(
+ void (*)
+ ()
+ __attribute__(())
+ __attribute__(())));
+
+ /* cover 'abstract_decl_lparen vararg_parameter_type_list T_RPAREN type_attribute_opt' */
+ sink(sizeof(
+ void (*)
+ (void)__attribute__(())));
+ /*
+ * XXX: The grammar allows only a single type_attribute_opt.
+ * Where does the second type_attribute go?
+ */
+ sink(sizeof(
+ void (*)
+ (void)__attribute__(())
+ __attribute__(())));
+
+ /* cover 'abstract_decl_lparen error T_RPAREN type_attribute_opt' */
+ /* expect+1: syntax error 'goto' [249] */
+ sink(sizeof(void (*)(goto)));
+ /* expect+1: syntax error 'goto' [249] */
+ sink(sizeof(void (*)(goto) __attribute__(())));
+ /*
+ * XXX: The grammar allows only a single type_attribute_opt.
+ * Where does the second type_attribute go?
+ */
+ /* expect+1: syntax error 'goto' [249] */
+ sink(sizeof(void (*)(goto) __attribute__(()) __attribute__(())));
+}
+
+void
+cover_vararg_parameter_type_list(void)
+{
+ /* cover 'parameter_type_list' */
+ sink(sizeof(void (*)(double)));
+
+ /* cover 'parameter_type_list T_COMMA T_ELLIPSIS' */
+ sink(sizeof(void (*)(double, ...)));
+
+ /* cover 'T_ELLIPSIS' */
+ /* expect+1: warning: ANSI C requires formal parameter before '...' [84] */
+ sink(sizeof(void (*)(...)));
+}
+
+void
+cover_parameter_type_list(void)
+{
+ /* cover 'parameter_declaration' */
+ sink(sizeof(void (*)(double)));
+
+ /* cover 'parameter_type_list T_COMMA parameter_declaration' */
+ sink(sizeof(void (*)(double, double, double, char *)));
+}
+
+void
+cover_parameter_declaration(void)
+{
+ /* cover 'declmods' */
+ /* GCC 11 warns: type defaults to 'int' in type name */
+ sink(sizeof(void (*)(int, const)));
+
+ /* cover 'declaration_specifiers' */
+ sink(sizeof(void (*)(int, double)));
+
+ /* cover 'declmods notype_param_declarator' */
+ /* GCC 11 warns: type defaults to 'int' in declaration of 'x' */
+ sink(sizeof(void (*)(int, const x)));
+
+ /* cover 'begin_type_declaration_specifiers end_type type_param_declarator' */
+ sink(sizeof(void (*)(int, double x)));
+
+ /* cover 'begin_type_declmods end_type abstract_declarator' */
+ /* GCC 11 warns: type defaults to 'int' in type name */
+ sink(sizeof(
+ void (*)(int, const *)));
+
+ /* cover 'begin_type_declaration_specifiers end_type abstract_declarator' */
+ sink(sizeof(void (*)(int, double *)));
+}
diff -r 575907741ac0 -r 6e053b27e668 tests/usr.bin/xlint/lint1/parse_type_name.exp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/parse_type_name.exp Sun Jul 25 08:42:28 2021 +0000
@@ -0,0 +1,6 @@
+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]
Home |
Main Index |
Thread Index |
Old Index