Sat Jul 10 18:25:57 2021 UTC ()
tests/lint: test declarations
(rillig)
diff -r1.1082 -r1.1083 src/distrib/sets/lists/tests/mi
diff -r1.83 -r1.84 src/tests/usr.bin/xlint/lint1/Makefile
diff -r0 -r1.1 src/tests/usr.bin/xlint/lint1/decl.c
diff -r0 -r1.1 src/tests/usr.bin/xlint/lint1/decl.exp
--- src/distrib/sets/lists/tests/mi 2021/07/10 09:24:26 1.1082
+++ src/distrib/sets/lists/tests/mi 2021/07/10 18:25:57 1.1083
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1082 2021/07/10 09:24:26 rillig Exp $
+# $NetBSD: mi,v 1.1083 2021/07/10 18:25:57 rillig Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@@ -6210,6 +6210,8 @@
./usr/tests/usr.bin/xlint/lint1/d_typefun.c tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/d_typename_as_var.c tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/d_zero_sized_arrays.c tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/decl.c tests-usr.bin-tests compattestfile,atf
+./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_struct_member.c tests-usr.bin-tests compattestfile,atf
--- src/tests/usr.bin/xlint/lint1/Makefile 2021/07/10 09:24:26 1.83
+++ src/tests/usr.bin/xlint/lint1/Makefile 2021/07/10 18:25:57 1.84
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.83 2021/07/10 09:24:26 rillig Exp $
+# $NetBSD: Makefile,v 1.84 2021/07/10 18:25:57 rillig Exp $
NOMAN= # defined
MAX_MESSAGE= 345 # see lint1/err.c
@@ -108,6 +108,8 @@
FILES+= d_typefun.c
FILES+= d_typename_as_var.c
FILES+= d_zero_sized_arrays.c
+FILES+= decl.c
+FILES+= decl.exp
FILES+= decl_arg.c
FILES+= decl_arg.exp
FILES+= decl_struct_member.c
/* $NetBSD: decl.c,v 1.1 2021/07/10 18:25:57 rillig Exp $ */
# 3 "decl.c"
/*
* Tests for declarations, especially the distinction between the
* declaration-specifiers and the declarators.
*/
/*
* Even though 'const' comes after 'char' and is therefore quite close to the
* first identifier, it applies to both identifiers.
*/
void
specifier_qualifier(void)
{
char const a = 1, b = 2;
/* expect+1: warning: left operand of '=' must be modifiable lvalue [115] */
a = 1;
/* expect+1: warning: left operand of '=' must be modifiable lvalue [115] */
b = 2;
}
/*
* Since 'const' comes before 'char', there is no ambiguity whether the
* 'const' applies to all variables or just to the first.
*/
void
qualifier_specifier(void)
{
const char a = 1, b = 2;
/* expect+1: warning: left operand of '=' must be modifiable lvalue [115] */
a = 3;
/* expect+1: warning: left operand of '=' must be modifiable lvalue [115] */
b = 5;
}
void
declarator_with_prefix_qualifier(void)
{
/* expect+1: syntax error 'const' [249] */
char a = 1, const b = 2;
a = 1;
/* expect+1: error: 'b' undefined [99] */
b = 2;
}
void
declarator_with_postfix_qualifier(void)
{
/* expect+1: syntax error 'const' [249] */
char a = 1, b const = 2;
a = 1;
b = 2;
}
void sink(double *);
void
declarators(void)
{
char *pc = 0, c = 0, **ppc = 0;
/* expect+1: warning: converting 'pointer to char' to incompatible 'pointer to double' */
sink(pc);
/* expect+1: warning: illegal combination of pointer (pointer to double) and integer (char) */
sink(c);
/* expect+1: converting 'pointer to pointer to char' to incompatible 'pointer to double' */
sink(ppc);
}
decl.c(19): warning: left operand of '=' must be modifiable lvalue [115]
decl.c(21): warning: left operand of '=' must be modifiable lvalue [115]
decl.c(34): warning: left operand of '=' must be modifiable lvalue [115]
decl.c(36): warning: left operand of '=' must be modifiable lvalue [115]
decl.c(43): error: syntax error 'const' [249]
decl.c(47): error: 'b' undefined [99]
decl.c(54): error: syntax error 'const' [249]
decl.c(68): warning: converting 'pointer to char' to incompatible 'pointer to double' for argument 1 [153]
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]