Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/tests/usr.bin/xlint/lint1 tests/lint: add tests for initiali...
details: https://anonhg.NetBSD.org/src/rev/f1d95d886a86
branches: trunk
changeset: 954073:f1d95d886a86
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Mar 28 18:48:32 2021 +0000
description:
tests/lint: add tests for initialization
diffstat:
tests/usr.bin/xlint/lint1/d_c99_init.c | 33 ++++++++++++++++++++++++++++---
tests/usr.bin/xlint/lint1/d_c99_init.exp | 10 +++++---
2 files changed, 35 insertions(+), 8 deletions(-)
diffs (78 lines):
diff -r d8e097aacbfc -r f1d95d886a86 tests/usr.bin/xlint/lint1/d_c99_init.c
--- a/tests/usr.bin/xlint/lint1/d_c99_init.c Sun Mar 28 18:33:27 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/d_c99_init.c Sun Mar 28 18:48:32 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: d_c99_init.c,v 1.17 2021/03/28 14:01:50 rillig Exp $ */
+/* $NetBSD: d_c99_init.c,v 1.18 2021/03/28 18:48:32 rillig Exp $ */
# 3 "d_c99_init.c"
/*
@@ -34,6 +34,9 @@
// See init_using_expr, initstack_string.
char static_duration[] = "static duration";
+signed char static_duration_signed[] = "static duration";
+unsigned char static_duration_unsigned[] = "static duration";
+int static_duration_wchar[] = L"static duration";
// See init_using_expr.
void
@@ -44,13 +47,25 @@
}
void
-initialization_with_redundant_braces(any arg)
+initialization_by_redundantly_braced_string(void)
+{
+ any local = {{{{ "hello" }}}};
+ use(&local);
+}
+
+/*
+ * Only scalar expressions and string literals may be enclosed by additional
+ * braces. Since 'arg' is a struct, this is a compile-time error.
+ */
+void
+initialization_with_too_many_braces(any arg)
{
any local = { arg }; /* expect: 185 */
use(&arg);
}
-// Some of the following examples are mentioned in init.c.
+// Some of the following examples are mentioned in the introduction comment
+// in init.c.
int number = 12345;
@@ -217,4 +232,14 @@
23456,
};
-// See d_struct_init_nested.c for a more complicated example.
+char prefixed_message[] = {
+ 'E', ':', ' ',
+ /* expect+1: illegal combination of integer (char) and pointer */
+ "message\n",
+};
+
+char message_with_suffix[] = {
+ "message",
+ /* expect+1: too many array initializers */
+ '\n',
+};
diff -r d8e097aacbfc -r f1d95d886a86 tests/usr.bin/xlint/lint1/d_c99_init.exp
--- a/tests/usr.bin/xlint/lint1/d_c99_init.exp Sun Mar 28 18:33:27 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/d_c99_init.exp Sun Mar 28 18:48:32 2021 +0000
@@ -1,5 +1,7 @@
d_c99_init.c(23): error: too many initializers [174]
-d_c99_init.c(49): error: cannot initialize 'pointer to const void' from 'struct any' [185]
-d_c99_init.c(65): error: too many array initializers, expected 3 [173]
-d_c99_init.c(130): error: syntax error 'named member must only be used with struct/union' [249]
-d_c99_init.c(217): error: too many struct/union initializers [172]
+d_c99_init.c(63): error: cannot initialize 'pointer to const void' from 'struct any' [185]
+d_c99_init.c(80): error: too many array initializers, expected 3 [173]
+d_c99_init.c(145): error: syntax error 'named member must only be used with struct/union' [249]
+d_c99_init.c(232): error: too many struct/union initializers [172]
+d_c99_init.c(238): warning: illegal combination of integer (char) and pointer (pointer to char) [183]
+d_c99_init.c(244): error: too many array initializers, expected 8 [173]
Home |
Main Index |
Thread Index |
Old Index