Source-Changes-HG archive

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

[src/trunk]: src lint: add another test for C99 initializers



details:   https://anonhg.NetBSD.org/src/rev/d6dc46235cb2
branches:  trunk
changeset: 952912:d6dc46235cb2
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Feb 21 08:05:51 2021 +0000

description:
lint: add another test for C99 initializers

diffstat:

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

diffs (78 lines):

diff -r 22b4bd5944b9 -r d6dc46235cb2 distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi       Sun Feb 21 08:01:14 2021 +0000
+++ b/distrib/sets/lists/tests/mi       Sun Feb 21 08:05:51 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1020 2021/02/19 12:28:56 rillig Exp $
+# $NetBSD: mi,v 1.1021 2021/02/21 08:05:51 rillig Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -5772,6 +5772,8 @@
 ./usr/tests/usr.bin/xlint/lint1/d_c99_flex_array_packed.c      tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/d_c99_for_loops.c              tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/d_c99_func.c                   tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/d_c99_init.c                   tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/d_c99_init.exp                 tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/d_c99_nested_struct.c          tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/d_c99_recursive_init.c         tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/d_c99_struct_init.c            tests-usr.bin-tests     compattestfile,atf
diff -r 22b4bd5944b9 -r d6dc46235cb2 tests/usr.bin/xlint/lint1/Makefile
--- a/tests/usr.bin/xlint/lint1/Makefile        Sun Feb 21 08:01:14 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/Makefile        Sun Feb 21 08:05:51 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.31 2021/02/19 12:28:56 rillig Exp $
+# $NetBSD: Makefile,v 1.32 2021/02/21 08:05:51 rillig Exp $
 
 NOMAN=         # defined
 
@@ -28,6 +28,8 @@
 FILES+=                d_c99_flex_array_packed.c
 FILES+=                d_c99_for_loops.c
 FILES+=                d_c99_func.c
+FILES+=                d_c99_init.c
+FILES+=                d_c99_init.exp
 FILES+=                d_c99_nested_struct.c
 FILES+=                d_c99_recursive_init.c
 FILES+=                d_c99_struct_init.c
diff -r 22b4bd5944b9 -r d6dc46235cb2 tests/usr.bin/xlint/lint1/d_c99_init.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/d_c99_init.c    Sun Feb 21 08:05:51 2021 +0000
@@ -0,0 +1,16 @@
+/*     $NetBSD: d_c99_init.c,v 1.1 2021/02/21 08:05:51 rillig Exp $    */
+# 3 "d_c99_init.c"
+
+/*
+ * Test C99 initializers.
+ *
+ * See C99 6.7.8 "Initialization".
+*/
+
+/* lint1-extra-flags: -p */
+
+// C99 6.7.8p11 says "optionally enclosed in braces".  The intended
+// interpretation is "optionally enclosed in a single pair of braces".
+int scalar_without_braces = 3;
+int scalar_with_optional_braces = { 3 };
+int scalar_with_too_many_braces = {{ 3 }};
diff -r 22b4bd5944b9 -r d6dc46235cb2 tests/usr.bin/xlint/lint1/d_c99_init.exp
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/d_c99_init.exp  Sun Feb 21 08:05:51 2021 +0000
@@ -0,0 +1,1 @@
+d_c99_init.c(16): invalid initializer type int [176]
diff -r 22b4bd5944b9 -r d6dc46235cb2 tests/usr.bin/xlint/lint1/t_integration.sh
--- a/tests/usr.bin/xlint/lint1/t_integration.sh        Sun Feb 21 08:01:14 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/t_integration.sh        Sun Feb 21 08:05:51 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: t_integration.sh,v 1.29 2021/02/19 12:28:56 rillig Exp $
+# $NetBSD: t_integration.sh,v 1.30 2021/02/21 08:05:51 rillig Exp $
 #
 # Copyright (c) 2008, 2010 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -98,6 +98,7 @@
 test_case c99_compound_literal_comma
 test_case c99_decls_after_stmt2
 test_case c99_flex_array_packed
+test_case c99_init
 test_case c99_nested_struct
 test_case c99_union_cast
 test_case c99_union_init4



Home | Main Index | Thread Index | Old Index