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: fix analysis from prev...
details: https://anonhg.NetBSD.org/src/rev/8dd75b6464da
branches: trunk
changeset: 961759:8dd75b6464da
user: rillig <rillig%NetBSD.org@localhost>
date: Sat Apr 17 20:57:18 2021 +0000
description:
tests/lint: fix analysis from previous commit, add another example
This is not a GCC feature, it's required by C99 already.
diffstat:
tests/usr.bin/xlint/lint1/gcc_init_compound_literal.c | 45 +++++++++++++---
tests/usr.bin/xlint/lint1/gcc_init_compound_literal.exp | 2 +-
2 files changed, 37 insertions(+), 10 deletions(-)
diffs (69 lines):
diff -r 532b0c87423a -r 8dd75b6464da tests/usr.bin/xlint/lint1/gcc_init_compound_literal.c
--- a/tests/usr.bin/xlint/lint1/gcc_init_compound_literal.c Sat Apr 17 20:42:57 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/gcc_init_compound_literal.c Sat Apr 17 20:57:18 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: gcc_init_compound_literal.c,v 1.1 2021/04/17 20:36:17 rillig Exp $ */
+/* $NetBSD: gcc_init_compound_literal.c,v 1.2 2021/04/17 20:57:18 rillig Exp $ */
# 3 "gcc_init_compound_literal.c"
/*
@@ -7,14 +7,11 @@
* All the expressions in an initializer for an object that has static
* storage duration shall be constant expressions or string literals.
*
- * The term "constant expression" is defined in C99 6.6 and is quite
- * restricted, except for a single paragraph, 6.6p10:
- *
- * An implementation may accept other forms of constant expressions.
- *
- * GCC additionally allows compound expressions, and these can even use the
- * array-to-pointer conversion from C99 6.3.2.1, which allows to initialize a
- * pointer object with a pointer to a direct-value statically allocated array.
+ * The term "constant expression" is defined in C99 6.6, where 6.6p9 allows
+ * "constant expressions" in initializers to also be an "address constant".
+ * Using these address constants, it is possible to reference an unnamed
+ * object created by a compound literal (C99 6.5.2.5), using either an
+ * explicit '&' or the implicit array-to-pointer conversion from C99 6.3.2.1.
*/
// Seen in sys/crypto/aes/aes_ccm.c.
@@ -28,3 +25,33 @@
// 1, 2, 3, 4
// },
};
+
+struct node {
+ int num;
+ struct node *left;
+ struct node *right;
+};
+
+/*
+ * Initial tree for representing the decisions in the classic number guessing
+ * game often used in teaching the basics of programming.
+ */
+/* TODO: activate after fixing the assertion failure
+static const struct node guess = {
+ 50,
+ &(struct node){
+ 25,
+ &(struct node){
+ 12,
+ (void *)0,
+ (void *)0,
+ },
+ &(struct node){
+ 37,
+ (void *)0,
+ (void *)0,
+ },
+ },
+ (void *)0
+};
+*/
diff -r 532b0c87423a -r 8dd75b6464da tests/usr.bin/xlint/lint1/gcc_init_compound_literal.exp
--- a/tests/usr.bin/xlint/lint1/gcc_init_compound_literal.exp Sat Apr 17 20:42:57 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/gcc_init_compound_literal.exp Sat Apr 17 20:57:18 2021 +0000
@@ -1,1 +1,1 @@
-gcc_init_compound_literal.c(25): error: too many struct/union initializers [172]
+gcc_init_compound_literal.c(22): error: too many struct/union initializers [172]
Home |
Main Index |
Thread Index |
Old Index