tests/lint: add test for typeof after statement

Found by christos@.
This commit is contained in:
rillig 2021-04-22 22:43:26 +00:00
parent 7e0fcb8493
commit 66445508cf
5 changed files with 34 additions and 3 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: mi,v 1.1044 2021/04/18 23:02:16 rillig Exp $
# $NetBSD: mi,v 1.1045 2021/04/22 22:43:26 rillig Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@ -6191,6 +6191,8 @@
./usr/tests/usr.bin/xlint/lint1/feat_stacktrace.exp tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/gcc_init_compound_literal.c tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/gcc_init_compound_literal.exp tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/gcc_typeof_after_statement.c tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/gcc_typeof_after_statement.exp tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/msg_000.c tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/msg_000.exp tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/msg_001.c tests-usr.bin-tests compattestfile,atf

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.51 2021/04/21 14:04:26 christos Exp $
# $NetBSD: Makefile,v 1.52 2021/04/22 22:43:26 rillig Exp $
NOMAN= # defined
MAX_MESSAGE= 343 # see lint1/err.c
@ -107,6 +107,8 @@ FILES+= feat_stacktrace.c
FILES+= feat_stacktrace.exp
FILES+= gcc_init_compound_literal.c
FILES+= gcc_init_compound_literal.exp
FILES+= gcc_typeof_after_statement.c
FILES+= gcc_typeof_after_statement.exp
FILES+= ${:U0 ${:U:${:Urange=${MAX_MESSAGE}}}:C,^.$,0&,:C,^..$,0&,:@i@msg_${i}.c msg_${i}.exp@:Nmsg_176.exp}
FILES+= op_colon.c
FILES+= op_colon.exp

View File

@ -0,0 +1,23 @@
/* $NetBSD: gcc_typeof_after_statement.c,v 1.1 2021/04/22 22:43:26 rillig Exp $ */
# 3 "gcc_typeof_after_statement.c"
/*
* As of 2021-04-23, lint cannot parse typeof(...) if there is a statement
* before it.
*/
void *
example(void **ptr)
{
return ({
if (*ptr != (void *)0)
ptr++;
/* FIXME: This is a legitimate use case. */
/* expect+1: syntax error '__typeof__' [249] */
__typeof__(*ptr) ret = *ptr;
/* expect+1: 'ret' undefined [99] */
ret;
/* expect+1: illegal combination of pointer (pointer to void) and integer (int) [183] */
});
}

View File

@ -0,0 +1,3 @@
gcc_typeof_after_statement.c(18): error: syntax error '__typeof__' [249]
gcc_typeof_after_statement.c(20): error: 'ret' undefined [99]
gcc_typeof_after_statement.c(22): warning: illegal combination of pointer (pointer to void) and integer (int) [183]

View File

@ -1,4 +1,4 @@
# $NetBSD: t_integration.sh,v 1.43 2021/04/18 20:02:56 rillig Exp $
# $NetBSD: t_integration.sh,v 1.44 2021/04/22 22:43:26 rillig Exp $
#
# Copyright (c) 2008, 2010 The NetBSD Foundation, Inc.
# All rights reserved.
@ -180,6 +180,7 @@ test_case d_long_double_int
test_case emit
test_case gcc_init_compound_literal
test_case gcc_typeof_after_statement
test_case op_colon