Source-Changes-HG archive

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

[src/trunk]: src tests/lint: demonstrate missing support for GCC typeof



details:   https://anonhg.NetBSD.org/src/rev/dd5050646220
branches:  trunk
changeset: 1022568:dd5050646220
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Jul 25 10:57:38 2021 +0000

description:
tests/lint: demonstrate missing support for GCC typeof

diffstat:

 distrib/sets/lists/tests/mi              |   4 ++-
 tests/usr.bin/xlint/lint1/Makefile       |   4 ++-
 tests/usr.bin/xlint/lint1/gcc_typeof.c   |  35 ++++++++++++++++++++++++++++++++
 tests/usr.bin/xlint/lint1/gcc_typeof.exp |   2 +
 4 files changed, 43 insertions(+), 2 deletions(-)

diffs (81 lines):

diff -r 31317e3ab645 -r dd5050646220 distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi       Sun Jul 25 10:39:10 2021 +0000
+++ b/distrib/sets/lists/tests/mi       Sun Jul 25 10:57:38 2021 +0000
@@ -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
diff -r 31317e3ab645 -r dd5050646220 tests/usr.bin/xlint/lint1/Makefile
--- a/tests/usr.bin/xlint/lint1/Makefile        Sun Jul 25 10:39:10 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/Makefile        Sun Jul 25 10:57:38 2021 +0000
@@ -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.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
diff -r 31317e3ab645 -r dd5050646220 tests/usr.bin/xlint/lint1/gcc_typeof.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/gcc_typeof.c    Sun Jul 25 10:57:38 2021 +0000
@@ -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);
+}
diff -r 31317e3ab645 -r dd5050646220 tests/usr.bin/xlint/lint1/gcc_typeof.exp
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/gcc_typeof.exp  Sun Jul 25 10:57:38 2021 +0000
@@ -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]



Home | Main Index | Thread Index | Old Index