Source-Changes-HG archive

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

[src/trunk]: src tests/lint: add test for typeof after statement



details:   https://anonhg.NetBSD.org/src/rev/63f7d7ccfece
branches:  trunk
changeset: 982671:63f7d7ccfece
user:      rillig <rillig%NetBSD.org@localhost>
date:      Thu Apr 22 22:43:26 2021 +0000

description:
tests/lint: add test for typeof after statement

Found by christos@.

diffstat:

 distrib/sets/lists/tests/mi                              |   4 ++-
 tests/usr.bin/xlint/lint1/Makefile                       |   4 ++-
 tests/usr.bin/xlint/lint1/gcc_typeof_after_statement.c   |  23 ++++++++++++++++
 tests/usr.bin/xlint/lint1/gcc_typeof_after_statement.exp |   3 ++
 tests/usr.bin/xlint/lint1/t_integration.sh               |   3 +-
 5 files changed, 34 insertions(+), 3 deletions(-)

diffs (87 lines):

diff -r 779817548882 -r 63f7d7ccfece distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi       Thu Apr 22 20:45:00 2021 +0000
+++ b/distrib/sets/lists/tests/mi       Thu Apr 22 22:43:26 2021 +0000
@@ -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
diff -r 779817548882 -r 63f7d7ccfece tests/usr.bin/xlint/lint1/Makefile
--- a/tests/usr.bin/xlint/lint1/Makefile        Thu Apr 22 20:45:00 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/Makefile        Thu Apr 22 22:43:26 2021 +0000
@@ -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.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
diff -r 779817548882 -r 63f7d7ccfece tests/usr.bin/xlint/lint1/gcc_typeof_after_statement.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/gcc_typeof_after_statement.c    Thu Apr 22 22:43:26 2021 +0000
@@ -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] */
+       });
+}
diff -r 779817548882 -r 63f7d7ccfece tests/usr.bin/xlint/lint1/gcc_typeof_after_statement.exp
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/gcc_typeof_after_statement.exp  Thu Apr 22 22:43:26 2021 +0000
@@ -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]
diff -r 779817548882 -r 63f7d7ccfece tests/usr.bin/xlint/lint1/t_integration.sh
--- a/tests/usr.bin/xlint/lint1/t_integration.sh        Thu Apr 22 20:45:00 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/t_integration.sh        Thu Apr 22 22:43:26 2021 +0000
@@ -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 emit
 
 test_case gcc_init_compound_literal
+test_case gcc_typeof_after_statement
 
 test_case op_colon
 



Home | Main Index | Thread Index | Old Index