Module Name: src
Committed By: rillig
Date: Sat Jun 8 09:09:20 UTC 2024
Modified Files:
src/distrib/sets/lists/tests: mi
src/tests/usr.bin/xlint/lint1: Makefile decl.c expr_fold_strict_bool.c
lang_level_c99.c msg_211.c
src/usr.bin/xlint/lint1: Makefile
Added Files:
src/tests/usr.bin/xlint/lint1: expr.c gcc.c
Removed Files:
src/tests/usr.bin/xlint/lint1: d_c99_for_loops.c d_c9x_array_init.c
d_cvt_constant.c d_cvt_in_ternary.c d_ellipsis_in_switch.c
d_gcc_extension.c d_gcc_func.c d_incorrect_array_size.c
d_long_double_int.c d_return_type.c d_typename_as_var.c
d_zero_sized_arrays.c
Log Message:
tests/lint: reorganize tests
Tests for a single working language construct don't usually need a
separate file, they can be grouped together, like in expr.c or gcc.c.
To generate a diff of this commit:
cvs rdiff -u -r1.1316 -r1.1317 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.141 -r1.142 src/tests/usr.bin/xlint/lint1/Makefile
cvs rdiff -u -r1.4 -r0 src/tests/usr.bin/xlint/lint1/d_c99_for_loops.c \
src/tests/usr.bin/xlint/lint1/d_c9x_array_init.c \
src/tests/usr.bin/xlint/lint1/d_gcc_func.c \
src/tests/usr.bin/xlint/lint1/d_incorrect_array_size.c
cvs rdiff -u -r1.6 -r0 src/tests/usr.bin/xlint/lint1/d_cvt_constant.c \
src/tests/usr.bin/xlint/lint1/d_long_double_int.c \
src/tests/usr.bin/xlint/lint1/d_return_type.c
cvs rdiff -u -r1.3 -r0 src/tests/usr.bin/xlint/lint1/d_cvt_in_ternary.c \
src/tests/usr.bin/xlint/lint1/d_zero_sized_arrays.c
cvs rdiff -u -r1.5 -r0 src/tests/usr.bin/xlint/lint1/d_ellipsis_in_switch.c
cvs rdiff -u -r1.7 -r0 src/tests/usr.bin/xlint/lint1/d_gcc_extension.c
cvs rdiff -u -r1.2 -r0 src/tests/usr.bin/xlint/lint1/d_typename_as_var.c
cvs rdiff -u -r1.30 -r1.31 src/tests/usr.bin/xlint/lint1/decl.c
cvs rdiff -u -r0 -r1.1 src/tests/usr.bin/xlint/lint1/expr.c \
src/tests/usr.bin/xlint/lint1/gcc.c
cvs rdiff -u -r1.2 -r1.3 \
src/tests/usr.bin/xlint/lint1/expr_fold_strict_bool.c
cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/xlint/lint1/lang_level_c99.c
cvs rdiff -u -r1.6 -r1.7 src/tests/usr.bin/xlint/lint1/msg_211.c
cvs rdiff -u -r1.105 -r1.106 src/usr.bin/xlint/lint1/Makefile
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.1316 src/distrib/sets/lists/tests/mi:1.1317
--- src/distrib/sets/lists/tests/mi:1.1316 Sat May 11 15:53:38 2024
+++ src/distrib/sets/lists/tests/mi Sat Jun 8 09:09:19 2024
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1316 2024/05/11 15:53:38 rillig Exp $
+# $NetBSD: mi,v 1.1317 2024/06/08 09:09:19 rillig Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@@ -6581,7 +6581,7 @@
./usr/tests/usr.bin/xlint/lint1/d_c99_decls_after_stmt2.c tests-obsolete obsolete,atf
./usr/tests/usr.bin/xlint/lint1/d_c99_decls_after_stmt3.c tests-obsolete obsolete,atf
./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_for_loops.c tests-obsolete obsolete,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-obsolete obsolete,atf
@@ -6595,7 +6595,7 @@
./usr/tests/usr.bin/xlint/lint1/d_c99_union_init3.c tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/d_c99_union_init4.c tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/d_c99_union_init5.c tests-usr.bin-tests compattestfile,atf
-./usr/tests/usr.bin/xlint/lint1/d_c9x_array_init.c tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/d_c9x_array_init.c tests-obsolete obsolete,atf
./usr/tests/usr.bin/xlint/lint1/d_c9x_recursive_init.c tests-obsolete obsolete,atf
./usr/tests/usr.bin/xlint/lint1/d_cast_fun_array_param.c tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/d_cast_init.c tests-obsolete obsolete,atf
@@ -6609,23 +6609,23 @@
./usr/tests/usr.bin/xlint/lint1/d_constant_conv1.exp tests-obsolete obsolete,atf
./usr/tests/usr.bin/xlint/lint1/d_constant_conv2.c tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/d_constant_conv2.exp tests-obsolete obsolete,atf
-./usr/tests/usr.bin/xlint/lint1/d_cvt_constant.c tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/d_cvt_constant.c tests-obsolete obsolete,atf
./usr/tests/usr.bin/xlint/lint1/d_cvt_constant.exp tests-obsolete obsolete,atf
-./usr/tests/usr.bin/xlint/lint1/d_cvt_in_ternary.c tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/d_cvt_in_ternary.c tests-obsolete obsolete,atf
./usr/tests/usr.bin/xlint/lint1/d_decl_old_style_arguments.c tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/d_decl_old_style_arguments.exp tests-obsolete obsolete,atf
-./usr/tests/usr.bin/xlint/lint1/d_ellipsis_in_switch.c tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/d_ellipsis_in_switch.c tests-obsolete obsolete,atf
./usr/tests/usr.bin/xlint/lint1/d_fold_test.c tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/d_fold_test.exp tests-obsolete obsolete,atf
./usr/tests/usr.bin/xlint/lint1/d_gcc_compound_statements1.c tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/d_gcc_compound_statements1.exp tests-obsolete obsolete,atf
./usr/tests/usr.bin/xlint/lint1/d_gcc_compound_statements2.c tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/d_gcc_compound_statements3.c tests-usr.bin-tests compattestfile,atf
-./usr/tests/usr.bin/xlint/lint1/d_gcc_extension.c tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/d_gcc_extension.c tests-obsolete obsolete,atf
./usr/tests/usr.bin/xlint/lint1/d_gcc_extension.exp tests-obsolete obsolete
-./usr/tests/usr.bin/xlint/lint1/d_gcc_func.c tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/d_gcc_func.c tests-obsolete obsolete,atf
./usr/tests/usr.bin/xlint/lint1/d_gcc_variable_array_init.c tests-usr.bin-tests compattestfile,atf
-./usr/tests/usr.bin/xlint/lint1/d_incorrect_array_size.c tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/d_incorrect_array_size.c tests-obsolete obsolete,atf
./usr/tests/usr.bin/xlint/lint1/d_incorrect_array_size.exp tests-obsolete obsolete,atf
./usr/tests/usr.bin/xlint/lint1/d_init_array_using_string.c tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/d_init_array_using_string.exp tests-obsolete obsolete,atf
@@ -6633,14 +6633,14 @@
./usr/tests/usr.bin/xlint/lint1/d_init_pop_member.exp tests-obsolete obsolete,atf
./usr/tests/usr.bin/xlint/lint1/d_lint_assert.c tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/d_lint_assert.exp tests-obsolete obsolete,atf
-./usr/tests/usr.bin/xlint/lint1/d_long_double_int.c tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/d_long_double_int.c tests-obsolete obsolete,atf
./usr/tests/usr.bin/xlint/lint1/d_long_double_int.exp tests-obsolete obsolete,atf
./usr/tests/usr.bin/xlint/lint1/d_nested_structs.c tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/d_nolimit_init.c tests-obsolete obsolete,atf
./usr/tests/usr.bin/xlint/lint1/d_packed_structs.c tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/d_pr_22119.c tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/d_pr_22119.exp tests-obsolete obsolete,atf
-./usr/tests/usr.bin/xlint/lint1/d_return_type.c tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/d_return_type.c tests-obsolete obsolete,atf
./usr/tests/usr.bin/xlint/lint1/d_return_type.exp tests-obsolete obsolete,atf
./usr/tests/usr.bin/xlint/lint1/d_shift_to_narrower_type.c tests-obsolete obsolete,atf
./usr/tests/usr.bin/xlint/lint1/d_struct_init_nested.c tests-usr.bin-tests compattestfile,atf
@@ -6653,8 +6653,8 @@
./usr/tests/usr.bin/xlint/lint1/d_type_conv3.exp tests-obsolete obsolete,atf
./usr/tests/usr.bin/xlint/lint1/d_type_question_colon.c tests-obsolete obsolete,atf
./usr/tests/usr.bin/xlint/lint1/d_typefun.c tests-usr.bin-tests compattestfile,atf
-./usr/tests/usr.bin/xlint/lint1/d_typename_as_var.c tests-usr.bin-tests compattestfile,atf
-./usr/tests/usr.bin/xlint/lint1/d_zero_sized_arrays.c tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/d_typename_as_var.c tests-obsolete obsolete,atf
+./usr/tests/usr.bin/xlint/lint1/d_zero_sized_arrays.c tests-obsolete obsolete,atf
./usr/tests/usr.bin/xlint/lint1/decl.c tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/decl.exp tests-obsolete obsolete,atf
./usr/tests/usr.bin/xlint/lint1/decl_arg.c tests-usr.bin-tests compattestfile,atf
@@ -6675,6 +6675,7 @@
./usr/tests/usr.bin/xlint/lint1/emit.ln tests-obsolete obsolete
./usr/tests/usr.bin/xlint/lint1/emit_lp64.c tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/emit_lp64.exp-ln tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/expr.c tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/expr_binary.c tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/expr_binary.exp tests-obsolete obsolete,atf
./usr/tests/usr.bin/xlint/lint1/expr_binary_trad.c tests-usr.bin-tests compattestfile,atf
@@ -6696,6 +6697,7 @@
./usr/tests/usr.bin/xlint/lint1/expr_sizeof.c tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/feat_stacktrace.c tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/feat_stacktrace.exp tests-obsolete obsolete,atf
+./usr/tests/usr.bin/xlint/lint1/gcc.c tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/gcc_attribute.c tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/gcc_attribute.exp tests-obsolete obsolete,atf
./usr/tests/usr.bin/xlint/lint1/gcc_attribute_aligned.c tests-usr.bin-tests compattestfile,atf
Index: src/tests/usr.bin/xlint/lint1/Makefile
diff -u src/tests/usr.bin/xlint/lint1/Makefile:1.141 src/tests/usr.bin/xlint/lint1/Makefile:1.142
--- src/tests/usr.bin/xlint/lint1/Makefile:1.141 Sun Apr 23 08:47:27 2023
+++ src/tests/usr.bin/xlint/lint1/Makefile Sat Jun 8 09:09:20 2024
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.141 2023/04/23 08:47:27 rillig Exp $
+# $NetBSD: Makefile,v 1.142 2024/06/08 09:09:20 rillig Exp $
NOMAN= # defined
@@ -20,6 +20,38 @@ FILESDIR= ${TESTSDIR}
FILES+= ${:!cd ${.CURDIR} && echo *.c *.exp-ln!}
FILES+= check-expect.lua
+add-test: .PHONY
+ @set -eu; \
+ test=${NAME:Q}; \
+ [ "$$test" ] || { \
+ echo "usage: ${MAKE} add-test NAME=<name>"; \
+ exit; \
+ }; \
+ \
+ if [ -f "$$test.c" ]; then \
+ echo "error: test $$test already exists in $$PWD."; \
+ exit 1; \
+ fi; \
+ \
+ echo "=> Adding test $$test"; \
+ printf '%s\n' \
+ '/* $$''NetBSD$$ */' \
+ "# 3 \"$$test.c\"" \
+ '' \
+ '/*' \
+ ' * TODO: Explain the purpose of the test.' \
+ ' */' \
+ '' \
+ '/* lint1-extra-flags: -Z */' \
+ '/* lint1-flags: -Z */' \
+ '/* lint1-only-if: schar uchar ilp32 lp64 int long ldbl64 ldbl96 ldbl128 */' \
+ '' \
+ '// TODO: Add some code that passes.' \
+ '// TODO: Add some code that fails.' \
+ > "$$test.c"; \
+ cvs add "$$test.c"; \
+ ${MAKE} sync-mi
+
# Note: only works for adding tests.
# To remove a test, the $$mi file must be edited manually.
sync-mi: .PHONY
Index: src/tests/usr.bin/xlint/lint1/decl.c
diff -u src/tests/usr.bin/xlint/lint1/decl.c:1.30 src/tests/usr.bin/xlint/lint1/decl.c:1.31
--- src/tests/usr.bin/xlint/lint1/decl.c:1.30 Wed May 1 17:42:57 2024
+++ src/tests/usr.bin/xlint/lint1/decl.c Sat Jun 8 09:09:20 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.30 2024/05/01 17:42:57 rillig Exp $ */
+/* $NetBSD: decl.c,v 1.31 2024/06/08 09:09:20 rillig Exp $ */
# 3 "decl.c"
/*
@@ -269,3 +269,34 @@ offsetof_on_array_member(void)
/* expect+1: error: negative array dimension (-20) [20] */
typedef int off_arr_3[-(int)(unsigned long)&((s1 *)0)->arr[3]];
}
+
+/* PR bin/39639: writing "long double" gave "long int" */
+int
+long_double_vs_long_int(long double *a, long int *b)
+{
+ /* expect+1: warning: illegal combination of 'pointer to long double' and 'pointer to long', op '==' [124] */
+ return a == b;
+}
+
+struct zero_sized_array {
+ int member[0];
+};
+
+void
+type_name_as_member_name(void)
+{
+ typedef char h[10];
+
+ typedef struct {
+ int i;
+ char *c;
+ } fh;
+
+ struct foo {
+ fh h;
+ struct {
+ int x;
+ int y;
+ } fl;
+ };
+}
Index: src/tests/usr.bin/xlint/lint1/expr_fold_strict_bool.c
diff -u src/tests/usr.bin/xlint/lint1/expr_fold_strict_bool.c:1.2 src/tests/usr.bin/xlint/lint1/expr_fold_strict_bool.c:1.3
--- src/tests/usr.bin/xlint/lint1/expr_fold_strict_bool.c:1.2 Sun Aug 22 21:17:04 2021
+++ src/tests/usr.bin/xlint/lint1/expr_fold_strict_bool.c Sat Jun 8 09:09:20 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: expr_fold_strict_bool.c,v 1.2 2021/08/22 21:17:04 rillig Exp $ */
+/* $NetBSD: expr_fold_strict_bool.c,v 1.3 2024/06/08 09:09:20 rillig Exp $ */
# 3 "expr_fold_strict_bool.c"
/*
@@ -9,7 +9,6 @@
*/
/* lint1-extra-flags: -T */
-/* lint1-only-if: lp64 */
typedef long long int64_t;
typedef unsigned long long uint64_t;
Index: src/tests/usr.bin/xlint/lint1/lang_level_c99.c
diff -u src/tests/usr.bin/xlint/lint1/lang_level_c99.c:1.3 src/tests/usr.bin/xlint/lint1/lang_level_c99.c:1.4
--- src/tests/usr.bin/xlint/lint1/lang_level_c99.c:1.3 Thu Mar 28 21:04:48 2024
+++ src/tests/usr.bin/xlint/lint1/lang_level_c99.c Sat Jun 8 09:09:20 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: lang_level_c99.c,v 1.3 2024/03/28 21:04:48 rillig Exp $ */
+/* $NetBSD: lang_level_c99.c,v 1.4 2024/06/08 09:09:20 rillig Exp $ */
# 3 "lang_level_c99.c"
/*
@@ -176,6 +176,18 @@ call_implicitly_declared_function(void)
// [x] mixed declarations and code
// [x] new block scopes for selection and iteration statements
+void
+for_scope(void)
+{
+ // A for loop may have a declaration in its first part.
+ for (int i = 0; i < 10; i++)
+ continue;
+
+ // Test that the scope of the previous i has ended.
+ for (int i = 0; i < 10; i++)
+ continue;
+}
+
// [?] integer constant type rules
//
Index: src/tests/usr.bin/xlint/lint1/msg_211.c
diff -u src/tests/usr.bin/xlint/lint1/msg_211.c:1.6 src/tests/usr.bin/xlint/lint1/msg_211.c:1.7
--- src/tests/usr.bin/xlint/lint1/msg_211.c:1.6 Fri Jul 7 19:45:22 2023
+++ src/tests/usr.bin/xlint/lint1/msg_211.c Sat Jun 8 09:09:20 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: msg_211.c,v 1.6 2023/07/07 19:45:22 rillig Exp $ */
+/* $NetBSD: msg_211.c,v 1.7 2024/06/08 09:09:20 rillig Exp $ */
# 3 "msg_211.c"
// Test for message: function has return type '%s' but returns '%s' [211]
@@ -22,3 +22,18 @@ return_int(double dbl, void *ptr, struct
return str;
return 3;
}
+
+enum A {
+ A
+};
+
+enum B {
+ B
+};
+
+enum A
+return_enum(enum B arg)
+{
+ /* expect+1: warning: function has return type 'enum A' but returns 'enum B' [211] */
+ return arg;
+}
Index: src/usr.bin/xlint/lint1/Makefile
diff -u src/usr.bin/xlint/lint1/Makefile:1.105 src/usr.bin/xlint/lint1/Makefile:1.106
--- src/usr.bin/xlint/lint1/Makefile:1.105 Sat Jun 8 06:42:59 2024
+++ src/usr.bin/xlint/lint1/Makefile Sat Jun 8 09:09:19 2024
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.105 2024/06/08 06:42:59 rillig Exp $
+# $NetBSD: Makefile,v 1.106 2024/06/08 09:09:19 rillig Exp $
.include <bsd.own.mk>
@@ -87,36 +87,6 @@ DPSRCS+= err-msgs.h
CPPFLAGS+= -I.
add-test: .PHONY
- @set -eu; \
- test=${NAME:Q}; \
- [ "$$test" ] || { \
- echo "usage: ${MAKE} add-test NAME=<name>"; \
- exit; \
- }; \
- \
- cd '../../../tests/usr.bin/xlint/lint1'; \
- if [ -f "$$test.c" ]; then \
- echo "error: test $$test already exists in $$PWD."; \
- exit 1; \
- fi; \
- \
- echo "=> Adding test $$test"; \
- printf '%s\n' \
- '/* $$''NetBSD$$ */' \
- "# 3 \"$$test.c\"" \
- '' \
- '/*' \
- ' * TODO: Explain the purpose of the test.' \
- ' */' \
- '' \
- '/* lint1-extra-flags: -Z */' \
- '/* lint1-flags: -Z */' \
- '/* lint1-only-if: schar uchar ilp32 lp64 int long ldbl64 ldbl96 ldbl128 */' \
- '' \
- '// TODO: Add some code that passes.' \
- '// TODO: Add some code that fails.' \
- > "$$test.c"; \
- cvs add "$$test.c"; \
- ${MAKE} sync-mi
+ @cd '../../../tests/usr.bin/xlint/lint1' && ${MAKE} add-test
.include <bsd.prog.mk>
Added files:
Index: src/tests/usr.bin/xlint/lint1/expr.c
diff -u /dev/null src/tests/usr.bin/xlint/lint1/expr.c:1.1
--- /dev/null Sat Jun 8 09:09:20 2024
+++ src/tests/usr.bin/xlint/lint1/expr.c Sat Jun 8 09:09:20 2024
@@ -0,0 +1,33 @@
+/* $NetBSD: expr.c,v 1.1 2024/06/08 09:09:20 rillig Exp $ */
+# 3 "expr.c"
+
+/*
+ * Miscellaneous tests for expressions.
+ */
+
+/* lint1-extra-flags: -X 351 */
+
+struct bit_fields {
+ unsigned u32: 32;
+};
+
+unsigned long
+expr_cond_cvt(unsigned long ul)
+{
+ struct bit_fields bits = { 0 };
+ // Combining 'unsigned:32' and 'unsigned long' in the ':' operator
+ // results in 'unsigned long'.
+ return bits.u32 < ul ? bits.u32 : ul;
+}
+
+// Before tree.c 1.76 from 2014-04-17, lint crashed with an internal error,
+// due to an uninitialized right operand of a tree node.
+void
+crash_in_assignment(void)
+{
+ /* expect+1: warning: 'x' set but not used in function 'crash_in_assignment' [191] */
+ double x = 1;
+ int foo = 0;
+ if (foo)
+ x = 1;
+}
Index: src/tests/usr.bin/xlint/lint1/gcc.c
diff -u /dev/null src/tests/usr.bin/xlint/lint1/gcc.c:1.1
--- /dev/null Sat Jun 8 09:09:20 2024
+++ src/tests/usr.bin/xlint/lint1/gcc.c Sat Jun 8 09:09:20 2024
@@ -0,0 +1,53 @@
+/* $NetBSD: gcc.c,v 1.1 2024/06/08 09:09:20 rillig Exp $ */
+# 3 "gcc.c"
+
+/*
+ * Miscellaneous tests that are specific to lint's GCC mode.
+ */
+
+/* lint1-extra-flags: -X 351 */
+
+// Before C99 introduced __func__, GCC already had __FUNCTION__ with the same
+// semantics.
+const char *
+gcc_function(void)
+{
+ // TODO: make __FUNCTION__ an array, then uncomment the code.
+ //typedef int size[-(int)sizeof __FUNCTION__];
+
+ return __FUNCTION__;
+}
+
+// Before C99 introduced designators in initializers, GCC already had them,
+// although with a different syntax for struct/union members and with the
+// a...b for ranges of array elements.
+int array_range_initializers[256] = {
+ [2] = 1,
+ [3] = 2,
+ [4 ... 5] = 3
+};
+
+_Bool dbl_isinf(double);
+
+// Test that the GCC '__extension__' and '__typeof' are recognized.
+void
+extension_and_typeof(void)
+{
+ double __logbw = 1;
+ if (__extension__(({
+ __typeof((__logbw)) x_ = (__logbw);
+ !dbl_isinf((x_));
+ })))
+ __logbw = 1;
+}
+
+int
+range_in_case_label(int i)
+{
+ switch (i) {
+ case 1 ... 40: // This is a GCC extension.
+ return 1;
+ default:
+ return 2;
+ }
+}