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 C23 tests



details:   https://anonhg.NetBSD.org/src/rev/52d40cca4c46
branches:  trunk
changeset: 377241:52d40cca4c46
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Jul 02 23:45:10 2023 +0000

description:
tests/lint: add C23 tests

diffstat:

 tests/usr.bin/xlint/lint1/c23.c     |  22 ++++++++++++++++++++++
 tests/usr.bin/xlint/lint1/msg_353.c |  19 +++++++++++++++++++
 2 files changed, 41 insertions(+), 0 deletions(-)

diffs (49 lines):

diff -r 4a712435a0ab -r 52d40cca4c46 tests/usr.bin/xlint/lint1/c23.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/c23.c   Sun Jul 02 23:45:10 2023 +0000
@@ -0,0 +1,22 @@
+/*     $NetBSD: c23.c,v 1.1 2023/07/02 23:45:10 rillig Exp $   */
+# 3 "c23.c"
+
+// Tests for the option -Ac23, which allows features from C23 and all earlier
+// ISO standards, but none of the GNU extensions.
+//
+// See also:
+//     msg_353.c
+
+/* lint1-flags: -Ac23 -w -X 351 */
+
+int
+c23(void)
+{
+       struct s {
+               int member;
+       } s;
+
+       s = (struct s){};
+       s = (struct s){s.member};
+       return s.member;
+}
diff -r 4a712435a0ab -r 52d40cca4c46 tests/usr.bin/xlint/lint1/msg_353.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_353.c       Sun Jul 02 23:45:10 2023 +0000
@@ -0,0 +1,19 @@
+/*     $NetBSD: msg_353.c,v 1.1 2023/07/02 23:45:10 rillig Exp $       */
+# 3 "msg_353.c"
+
+// Test for message 353: empty initializer braces require C23 or later [353]
+//
+// See also:
+//     c23.c
+
+void
+c23(void)
+{
+       struct s {
+               int member;
+       } s;
+
+       /* expect+1: error: empty initializer braces require C23 or later [353] */
+       s = (struct s){};
+       s = (struct s){0};
+}



Home | Main Index | Thread Index | Old Index