Module Name: src Committed By: rillig Date: Sun Jul 25 10:57:38 UTC 2021
Modified Files: src/distrib/sets/lists/tests: mi src/tests/usr.bin/xlint/lint1: Makefile Added Files: src/tests/usr.bin/xlint/lint1: gcc_typeof.c gcc_typeof.exp Log Message: tests/lint: demonstrate missing support for GCC typeof To generate a diff of this commit: cvs rdiff -u -r1.1093 -r1.1094 src/distrib/sets/lists/tests/mi cvs rdiff -u -r1.94 -r1.95 src/tests/usr.bin/xlint/lint1/Makefile cvs rdiff -u -r0 -r1.1 src/tests/usr.bin/xlint/lint1/gcc_typeof.c \ src/tests/usr.bin/xlint/lint1/gcc_typeof.exp Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/distrib/sets/lists/tests/mi diff -u src/distrib/sets/lists/tests/mi:1.1093 src/distrib/sets/lists/tests/mi:1.1094 --- src/distrib/sets/lists/tests/mi:1.1093 Sun Jul 25 09:29:20 2021 +++ src/distrib/sets/lists/tests/mi Sun Jul 25 10:57:38 2021 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.1093 2021/07/25 09:29:20 rillig Exp $ +# $NetBSD: mi,v 1.1094 2021/07/25 10:57:38 rillig Exp $ # # Note: don't delete entries from here - mark them as "obsolete" instead. # @@ -6258,6 +6258,8 @@ ./usr/tests/usr.bin/xlint/lint1/gcc_init_compound_literal.exp tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/xlint/lint1/gcc_stmt_asm.c tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/xlint/lint1/gcc_stmt_asm.exp tests-usr.bin-tests compattestfile,atf +./usr/tests/usr.bin/xlint/lint1/gcc_typeof.c tests-usr.bin-tests compattestfile,atf +./usr/tests/usr.bin/xlint/lint1/gcc_typeof.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/init.c tests-usr.bin-tests compattestfile,atf Index: src/tests/usr.bin/xlint/lint1/Makefile diff -u src/tests/usr.bin/xlint/lint1/Makefile:1.94 src/tests/usr.bin/xlint/lint1/Makefile:1.95 --- src/tests/usr.bin/xlint/lint1/Makefile:1.94 Sun Jul 25 09:29:20 2021 +++ src/tests/usr.bin/xlint/lint1/Makefile Sun Jul 25 10:57:38 2021 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.94 2021/07/25 09:29:20 rillig Exp $ +# $NetBSD: Makefile,v 1.95 2021/07/25 10:57:38 rillig Exp $ NOMAN= # defined MAX_MESSAGE= 345 # see lint1/err.c @@ -156,6 +156,8 @@ FILES+= gcc_init_compound_literal.c FILES+= gcc_init_compound_literal.exp FILES+= gcc_stmt_asm.c FILES+= gcc_stmt_asm.exp +FILES+= gcc_typeof.c +FILES+= gcc_typeof.exp FILES+= gcc_typeof_after_statement.c FILES+= gcc_typeof_after_statement.exp FILES+= init.c Added files: Index: src/tests/usr.bin/xlint/lint1/gcc_typeof.c diff -u /dev/null src/tests/usr.bin/xlint/lint1/gcc_typeof.c:1.1 --- /dev/null Sun Jul 25 10:57:38 2021 +++ src/tests/usr.bin/xlint/lint1/gcc_typeof.c Sun Jul 25 10:57:38 2021 @@ -0,0 +1,35 @@ +/* $NetBSD: gcc_typeof.c,v 1.1 2021/07/25 10:57:38 rillig Exp $ */ +# 3 "gcc_typeof.c" + +/* + * Tests for the GCC extension 'typeof'. + * + * https://gcc.gnu.org/onlinedocs/gcc/Typeof.html + */ + +void take_double(typeof(0.0)); + +void take_function_double_returning_double( + typeof(0.0)( + /* FIXME: GCC can parse this */ + /* expect+1: error: syntax error 'typeof' [249] */ + typeof(0.0) + ) +); + +void +cast(double(*fn)(double)) +{ + take_double(0.0); + + /* expect+1: warning: passing 'pointer to function(double) returning double' to incompatible 'double', arg #1 [155] */ + take_double(fn); + + /* XXX: oops; GCC detects this type mismatch. probably due to the parse error. */ + take_function_double_returning_double(0.0); + + take_function_double_returning_double(fn); + + /* identity cast */ + take_function_double_returning_double((double (*)(double))fn); +} Index: src/tests/usr.bin/xlint/lint1/gcc_typeof.exp diff -u /dev/null src/tests/usr.bin/xlint/lint1/gcc_typeof.exp:1.1 --- /dev/null Sun Jul 25 10:57:38 2021 +++ src/tests/usr.bin/xlint/lint1/gcc_typeof.exp Sun Jul 25 10:57:38 2021 @@ -0,0 +1,2 @@ +gcc_typeof.c(16): error: syntax error 'typeof' [249] +gcc_typeof.c(26): warning: passing 'pointer to function(double) returning double' to incompatible 'double', arg #1 [155]