summaryrefslogtreecommitdiff
path: root/usr.bin/xlint
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/xlint')
-rw-r--r--usr.bin/xlint/Makefile9
-rw-r--r--usr.bin/xlint/lint1/Makefile55
-rw-r--r--usr.bin/xlint/lint1/d_alignof.c6
-rw-r--r--usr.bin/xlint/lint1/d_c99_complex_num.c7
-rw-r--r--usr.bin/xlint/lint1/d_c99_complex_split.c8
-rw-r--r--usr.bin/xlint/lint1/d_c99_decls_after_stmt.c5
-rw-r--r--usr.bin/xlint/lint1/d_c99_decls_after_stmt2.c6
-rw-r--r--usr.bin/xlint/lint1/d_c99_decls_after_stmt3.c5
-rw-r--r--usr.bin/xlint/lint1/d_c99_for_loops.c15
-rw-r--r--usr.bin/xlint/lint1/d_c99_func.c7
-rw-r--r--usr.bin/xlint/lint1/d_c99_recursive_init.c13
-rw-r--r--usr.bin/xlint/lint1/d_c99_struct_init.c10
-rw-r--r--usr.bin/xlint/lint1/d_c99_union_init1.c8
-rw-r--r--usr.bin/xlint/lint1/d_c99_union_init2.c8
-rw-r--r--usr.bin/xlint/lint1/d_c99_union_init3.c8
-rw-r--r--usr.bin/xlint/lint1/d_c9x_array_init.c6
-rw-r--r--usr.bin/xlint/lint1/d_c9x_recursive_init.c16
-rw-r--r--usr.bin/xlint/lint1/d_cast_init.c27
-rw-r--r--usr.bin/xlint/lint1/d_cast_init2.c7
-rw-r--r--usr.bin/xlint/lint1/d_cast_lhs.c7
-rw-r--r--usr.bin/xlint/lint1/d_compound_literals1.c11
-rw-r--r--usr.bin/xlint/lint1/d_compound_literals2.c18
-rw-r--r--usr.bin/xlint/lint1/d_constant_conv1.c9
-rw-r--r--usr.bin/xlint/lint1/d_constant_conv2.c9
-rw-r--r--usr.bin/xlint/lint1/d_cvt_constant.c8
-rw-r--r--usr.bin/xlint/lint1/d_cvt_in_ternary.c13
-rw-r--r--usr.bin/xlint/lint1/d_ellipsis_in_switch.c11
-rw-r--r--usr.bin/xlint/lint1/d_gcc_compound_statements1.c7
-rw-r--r--usr.bin/xlint/lint1/d_gcc_compound_statements2.c14
-rw-r--r--usr.bin/xlint/lint1/d_gcc_compound_statements3.c10
-rw-r--r--usr.bin/xlint/lint1/d_gcc_extension.c6
-rw-r--r--usr.bin/xlint/lint1/d_gcc_func.c7
-rw-r--r--usr.bin/xlint/lint1/d_gcc_variable_array_init.c7
-rw-r--r--usr.bin/xlint/lint1/d_incorrect_array_size.c3
-rw-r--r--usr.bin/xlint/lint1/d_long_double_int.c7
-rw-r--r--usr.bin/xlint/lint1/d_nested_structs.c21
-rw-r--r--usr.bin/xlint/lint1/d_nolimit_init.c4
-rw-r--r--usr.bin/xlint/lint1/d_packed_structs.c35
-rw-r--r--usr.bin/xlint/lint1/d_shift_to_narrower_type.c24
-rw-r--r--usr.bin/xlint/lint1/d_type_conv1.c11
-rw-r--r--usr.bin/xlint/lint1/d_type_conv2.c11
-rw-r--r--usr.bin/xlint/lint1/d_type_conv3.c10
-rw-r--r--usr.bin/xlint/lint1/d_typename_as_var.c14
-rw-r--r--usr.bin/xlint/lint1/d_zero_sized_arrays.c3
-rwxr-xr-xusr.bin/xlint/lint1/t_integration.sh132
45 files changed, 638 insertions, 0 deletions
diff --git a/usr.bin/xlint/Makefile b/usr.bin/xlint/Makefile
new file mode 100644
index 000000000000..3ab3f1abca70
--- /dev/null
+++ b/usr.bin/xlint/Makefile
@@ -0,0 +1,9 @@
+# $NetBSD: Makefile,v 1.1 2012/03/17 16:33:15 jruoho Exp $
+
+.include <bsd.own.mk>
+
+TESTSDIR= ${TESTSBASE}/usr.bin/xlint
+
+TESTS_SUBDIRS= lint1
+
+.include <bsd.test.mk>
diff --git a/usr.bin/xlint/lint1/Makefile b/usr.bin/xlint/lint1/Makefile
new file mode 100644
index 000000000000..9f2bed6f9780
--- /dev/null
+++ b/usr.bin/xlint/lint1/Makefile
@@ -0,0 +1,55 @@
+# $NetBSD: Makefile,v 1.3 2014/04/17 18:34:44 christos Exp $
+
+NOMAN= # defined
+
+.include <bsd.own.mk>
+
+TESTSDIR= ${TESTSBASE}/usr.bin/xlint/lint1
+
+TESTS_SH= t_integration
+
+FILESDIR= ${TESTSDIR}
+FILES+= d_alignof.c
+FILES+= d_c99_complex_num.c
+FILES+= d_c99_complex_split.c
+FILES+= d_c99_decls_after_stmt.c
+FILES+= d_c99_decls_after_stmt2.c
+FILES+= d_c99_decls_after_stmt3.c
+FILES+= d_c99_for_loops.c
+FILES+= d_c99_func.c
+FILES+= d_c99_recursive_init.c
+FILES+= d_c99_struct_init.c
+FILES+= d_c99_union_init1.c
+FILES+= d_c99_union_init2.c
+FILES+= d_c99_union_init3.c
+FILES+= d_c9x_array_init.c
+FILES+= d_c9x_recursive_init.c
+FILES+= d_cast_init.c
+FILES+= d_cast_init2.c
+FILES+= d_cast_lhs.c
+FILES+= d_compound_literals1.c
+FILES+= d_compound_literals2.c
+FILES+= d_constant_conv1.c
+FILES+= d_constant_conv2.c
+FILES+= d_cvt_in_ternary.c
+FILES+= d_cvt_constant.c
+FILES+= d_ellipsis_in_switch.c
+FILES+= d_gcc_compound_statements1.c
+FILES+= d_gcc_compound_statements2.c
+FILES+= d_gcc_compound_statements3.c
+FILES+= d_gcc_extension.c
+FILES+= d_gcc_func.c
+FILES+= d_gcc_variable_array_init.c
+FILES+= d_incorrect_array_size.c
+FILES+= d_long_double_int.c
+FILES+= d_nested_structs.c
+FILES+= d_nolimit_init.c
+FILES+= d_packed_structs.c
+FILES+= d_shift_to_narrower_type.c
+FILES+= d_type_conv1.c
+FILES+= d_type_conv2.c
+FILES+= d_type_conv3.c
+FILES+= d_typename_as_var.c
+FILES+= d_zero_sized_arrays.c
+
+.include <bsd.test.mk>
diff --git a/usr.bin/xlint/lint1/d_alignof.c b/usr.bin/xlint/lint1/d_alignof.c
new file mode 100644
index 000000000000..4a661346305b
--- /dev/null
+++ b/usr.bin/xlint/lint1/d_alignof.c
@@ -0,0 +1,6 @@
+/* __alignof__ */
+int
+main(void)
+{
+ return __alignof__(short);
+}
diff --git a/usr.bin/xlint/lint1/d_c99_complex_num.c b/usr.bin/xlint/lint1/d_c99_complex_num.c
new file mode 100644
index 000000000000..c3c952e7b722
--- /dev/null
+++ b/usr.bin/xlint/lint1/d_c99_complex_num.c
@@ -0,0 +1,7 @@
+double cabs(double _Complex);
+
+double cabs(double _Complex foo)
+{
+ double d = __real__ foo;
+ return d + 0.1fi;
+}
diff --git a/usr.bin/xlint/lint1/d_c99_complex_split.c b/usr.bin/xlint/lint1/d_c99_complex_split.c
new file mode 100644
index 000000000000..7b3d1a1d501e
--- /dev/null
+++ b/usr.bin/xlint/lint1/d_c99_complex_split.c
@@ -0,0 +1,8 @@
+int b(double a) {
+ return a == 0;
+}
+void a(void) {
+ double _Complex z = 0;
+ if (b(__real__ z) && b(__imag__ z))
+ return;
+}
diff --git a/usr.bin/xlint/lint1/d_c99_decls_after_stmt.c b/usr.bin/xlint/lint1/d_c99_decls_after_stmt.c
new file mode 100644
index 000000000000..f32a963c76b0
--- /dev/null
+++ b/usr.bin/xlint/lint1/d_c99_decls_after_stmt.c
@@ -0,0 +1,5 @@
+void sample(void)
+{
+ int i = 0; i += 1;
+ int j = 0; j += 1;
+}
diff --git a/usr.bin/xlint/lint1/d_c99_decls_after_stmt2.c b/usr.bin/xlint/lint1/d_c99_decls_after_stmt2.c
new file mode 100644
index 000000000000..960d392350ca
--- /dev/null
+++ b/usr.bin/xlint/lint1/d_c99_decls_after_stmt2.c
@@ -0,0 +1,6 @@
+typedef int int_t;
+int main(void) {
+int i = 0; i += 1;
+int_t j = 0; j += 1;
+return 0;
+}
diff --git a/usr.bin/xlint/lint1/d_c99_decls_after_stmt3.c b/usr.bin/xlint/lint1/d_c99_decls_after_stmt3.c
new file mode 100644
index 000000000000..278fe1bb713c
--- /dev/null
+++ b/usr.bin/xlint/lint1/d_c99_decls_after_stmt3.c
@@ -0,0 +1,5 @@
+void sample(int i)
+{
+ i += 1;
+ int j = 0; j += 1;
+}
diff --git a/usr.bin/xlint/lint1/d_c99_for_loops.c b/usr.bin/xlint/lint1/d_c99_for_loops.c
new file mode 100644
index 000000000000..48e380cb3600
--- /dev/null
+++ b/usr.bin/xlint/lint1/d_c99_for_loops.c
@@ -0,0 +1,15 @@
+/* c99 for loops */
+extern void foo(int);
+
+int
+main(void)
+{
+ // Test the basic functionality
+ for (int i = 0; i < 10; i++)
+ foo(i);
+
+ // Test that the scope of the iterator is correct
+ for (int i = 0; i < 10; i++)
+ continue;
+ return 0;
+}
diff --git a/usr.bin/xlint/lint1/d_c99_func.c b/usr.bin/xlint/lint1/d_c99_func.c
new file mode 100644
index 000000000000..b827bfa9f6bc
--- /dev/null
+++ b/usr.bin/xlint/lint1/d_c99_func.c
@@ -0,0 +1,7 @@
+/* C99 __func__ */
+
+void
+foo(const char *p) {
+ p = __func__;
+ foo(p);
+}
diff --git a/usr.bin/xlint/lint1/d_c99_recursive_init.c b/usr.bin/xlint/lint1/d_c99_recursive_init.c
new file mode 100644
index 000000000000..347644ffe107
--- /dev/null
+++ b/usr.bin/xlint/lint1/d_c99_recursive_init.c
@@ -0,0 +1,13 @@
+/* C99 recursive struct/union initialization */
+struct top {
+ int i;
+ char c;
+ union onion {
+ short us;
+ char uc;
+ } u;
+ char *s;
+} c[] = {
+ { .s = "foo", .c = 'b', .u = { .uc = 'c' } },
+ { .i = 1, .c = 'a', .u = { .us = 2 } },
+};
diff --git a/usr.bin/xlint/lint1/d_c99_struct_init.c b/usr.bin/xlint/lint1/d_c99_struct_init.c
new file mode 100644
index 000000000000..a94cbd163897
--- /dev/null
+++ b/usr.bin/xlint/lint1/d_c99_struct_init.c
@@ -0,0 +1,10 @@
+/* C99 struct initialization */
+struct {
+ int i;
+ char *s;
+} c[] = {
+ { .i = 2, },
+ { .s = "foo" },
+ { .i = 1, .s = "bar" },
+ { .s = "foo", .i = -1 },
+};
diff --git a/usr.bin/xlint/lint1/d_c99_union_init1.c b/usr.bin/xlint/lint1/d_c99_union_init1.c
new file mode 100644
index 000000000000..0e1a1a8323d9
--- /dev/null
+++ b/usr.bin/xlint/lint1/d_c99_union_init1.c
@@ -0,0 +1,8 @@
+/* C99 union initialization */
+union {
+ int i;
+ char *s;
+} c[] = {
+ { i: 1 },
+ { s: "foo" }
+};
diff --git a/usr.bin/xlint/lint1/d_c99_union_init2.c b/usr.bin/xlint/lint1/d_c99_union_init2.c
new file mode 100644
index 000000000000..51d34d450f21
--- /dev/null
+++ b/usr.bin/xlint/lint1/d_c99_union_init2.c
@@ -0,0 +1,8 @@
+/* C99 union initialization */
+union {
+ int i[10];
+ short s;
+} c[] = {
+ { s: 2 },
+ { i: { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 } },
+};
diff --git a/usr.bin/xlint/lint1/d_c99_union_init3.c b/usr.bin/xlint/lint1/d_c99_union_init3.c
new file mode 100644
index 000000000000..f5e8b59f4621
--- /dev/null
+++ b/usr.bin/xlint/lint1/d_c99_union_init3.c
@@ -0,0 +1,8 @@
+/* C99 union initialization */
+struct {
+ int i[10];
+ char *s;
+} c[] = {
+ { { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 },
+ "foo" },
+};
diff --git a/usr.bin/xlint/lint1/d_c9x_array_init.c b/usr.bin/xlint/lint1/d_c9x_array_init.c
new file mode 100644
index 000000000000..66f0e9ec158e
--- /dev/null
+++ b/usr.bin/xlint/lint1/d_c9x_array_init.c
@@ -0,0 +1,6 @@
+/* C9X array initializers */
+int foo[256] = {
+ [2] = 1,
+ [3] = 2,
+ [4 ... 5] = 3
+};
diff --git a/usr.bin/xlint/lint1/d_c9x_recursive_init.c b/usr.bin/xlint/lint1/d_c9x_recursive_init.c
new file mode 100644
index 000000000000..df907cd7a3cd
--- /dev/null
+++ b/usr.bin/xlint/lint1/d_c9x_recursive_init.c
@@ -0,0 +1,16 @@
+/* C9X struct/union member init, with nested union and trailing member */
+union node {
+ void *next;
+ char *data;
+};
+struct foo {
+ int b;
+ union node n;
+ int c;
+};
+
+struct foo f = {
+ .b = 1,
+ .n = { .next = 0, },
+ .c = 1
+};
diff --git a/usr.bin/xlint/lint1/d_cast_init.c b/usr.bin/xlint/lint1/d_cast_init.c
new file mode 100644
index 000000000000..36986e800ac4
--- /dev/null
+++ b/usr.bin/xlint/lint1/d_cast_init.c
@@ -0,0 +1,27 @@
+/* cast initialization */
+typedef unsigned char u_char;
+typedef unsigned int size_t;
+struct sockaddr_x25 {
+ u_char x25_len;
+ u_char x25_family;
+ short x25_net;
+ char x25_addr[16];
+ struct x25opts {
+ char op_flags;
+ char op_psize;
+ char op_wsize;
+ char op_speed;
+ } x25_opts;
+ short x25_udlen;
+ char x25_udata[16];
+};
+
+struct sockaddr_x25 x25_dgmask = {
+ (unsigned char)(unsigned char)(unsigned int)(unsigned long)(&((( struct sockaddr_x25 *)0)->x25_udata[1])) ,
+ 0,
+ 0,
+ {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+ {0, 0, 0, 0},
+ -1,
+ {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+};
diff --git a/usr.bin/xlint/lint1/d_cast_init2.c b/usr.bin/xlint/lint1/d_cast_init2.c
new file mode 100644
index 000000000000..9597d3580397
--- /dev/null
+++ b/usr.bin/xlint/lint1/d_cast_init2.c
@@ -0,0 +1,7 @@
+/* cast initialization as the rhs of a - operand */
+struct sockaddr_dl {
+ char sdl_data[2];
+};
+
+int npdl_datasize = sizeof(struct sockaddr_dl) -
+((int) ((unsigned long)&((struct sockaddr_dl *) 0)->sdl_data[0]));
diff --git a/usr.bin/xlint/lint1/d_cast_lhs.c b/usr.bin/xlint/lint1/d_cast_lhs.c
new file mode 100644
index 000000000000..eb865695535f
--- /dev/null
+++ b/usr.bin/xlint/lint1/d_cast_lhs.c
@@ -0,0 +1,7 @@
+/* pointer casts are valid lhs lvalues */
+struct sockaddr { };
+void
+foo() {
+ unsigned long p = 6;
+ ((struct sockaddr *)p) = 0;
+}
diff --git a/usr.bin/xlint/lint1/d_compound_literals1.c b/usr.bin/xlint/lint1/d_compound_literals1.c
new file mode 100644
index 000000000000..cd1987ae17de
--- /dev/null
+++ b/usr.bin/xlint/lint1/d_compound_literals1.c
@@ -0,0 +1,11 @@
+/* compound literals */
+
+struct p {
+ short a, b, c, d;
+};
+
+foo()
+{
+ struct p me = (struct p) {1, 2, 3, 4};
+ me.a = me.b;
+}
diff --git a/usr.bin/xlint/lint1/d_compound_literals2.c b/usr.bin/xlint/lint1/d_compound_literals2.c
new file mode 100644
index 000000000000..e4ffb929873f
--- /dev/null
+++ b/usr.bin/xlint/lint1/d_compound_literals2.c
@@ -0,0 +1,18 @@
+/* compound literals */
+
+struct p {
+ short a, b, c, d;
+} zz = {
+ 1, 2, 3, 4
+};
+
+struct p *bar(int i)
+{
+ static struct p q[10];
+ return &q[i];
+}
+
+foo()
+{
+ *bar(1) = (struct p) { 1, 2, 3, 4 };
+}
diff --git a/usr.bin/xlint/lint1/d_constant_conv1.c b/usr.bin/xlint/lint1/d_constant_conv1.c
new file mode 100644
index 000000000000..53795c5fe858
--- /dev/null
+++ b/usr.bin/xlint/lint1/d_constant_conv1.c
@@ -0,0 +1,9 @@
+/* Flag information-losing constant conversion in argument lists */
+
+int f(unsigned int);
+
+void
+should_fail()
+{
+ f(-1);
+}
diff --git a/usr.bin/xlint/lint1/d_constant_conv2.c b/usr.bin/xlint/lint1/d_constant_conv2.c
new file mode 100644
index 000000000000..87066c96b5a8
--- /dev/null
+++ b/usr.bin/xlint/lint1/d_constant_conv2.c
@@ -0,0 +1,9 @@
+/* Flag information-losing constant conversion in argument lists */
+
+int f(unsigned int);
+
+void
+should_fail()
+{
+ f(2.1);
+}
diff --git a/usr.bin/xlint/lint1/d_cvt_constant.c b/usr.bin/xlint/lint1/d_cvt_constant.c
new file mode 100644
index 000000000000..aa74509fa42e
--- /dev/null
+++ b/usr.bin/xlint/lint1/d_cvt_constant.c
@@ -0,0 +1,8 @@
+/* the second assignment assumes failed before */
+int
+main(void) {
+ double x = 1;
+ int foo = 0;
+ if (foo)
+ x = 1;
+}
diff --git a/usr.bin/xlint/lint1/d_cvt_in_ternary.c b/usr.bin/xlint/lint1/d_cvt_in_ternary.c
new file mode 100644
index 000000000000..4a6149c67224
--- /dev/null
+++ b/usr.bin/xlint/lint1/d_cvt_in_ternary.c
@@ -0,0 +1,13 @@
+/* CVT node handling in ?: operator */
+typedef unsigned long int size_t;
+struct filecore_direntry {
+ unsigned len:32;
+};
+int
+main(void)
+{
+ struct filecore_direntry dirent = { 0 };
+ size_t uio_resid = 0;
+ size_t bytelen = (((dirent.len)<(uio_resid))?(dirent.len):(uio_resid));
+ return bytelen;
+}
diff --git a/usr.bin/xlint/lint1/d_ellipsis_in_switch.c b/usr.bin/xlint/lint1/d_ellipsis_in_switch.c
new file mode 100644
index 000000000000..ba4a338d29ae
--- /dev/null
+++ b/usr.bin/xlint/lint1/d_ellipsis_in_switch.c
@@ -0,0 +1,11 @@
+int x(void)
+{
+ int i = 33;
+ switch (i) {
+ case 1 ... 40:
+ break;
+ default:
+ break;
+ }
+ return 0;
+}
diff --git a/usr.bin/xlint/lint1/d_gcc_compound_statements1.c b/usr.bin/xlint/lint1/d_gcc_compound_statements1.c
new file mode 100644
index 000000000000..d970be182648
--- /dev/null
+++ b/usr.bin/xlint/lint1/d_gcc_compound_statements1.c
@@ -0,0 +1,7 @@
+/* GCC compound statements */
+
+foo(unsigned long z)
+{
+ z = ({ unsigned long tmp; tmp = 1; tmp; });
+ foo(z);
+}
diff --git a/usr.bin/xlint/lint1/d_gcc_compound_statements2.c b/usr.bin/xlint/lint1/d_gcc_compound_statements2.c
new file mode 100644
index 000000000000..fa1ee67302c5
--- /dev/null
+++ b/usr.bin/xlint/lint1/d_gcc_compound_statements2.c
@@ -0,0 +1,14 @@
+/* GCC compound statements with non-expressions */
+struct cpu_info {
+ int bar;
+};
+
+int
+main(void)
+{
+ return ({
+ struct cpu_info *__ci;
+ __asm__ volatile("movl %%fs:4,%0":"=r" (__ci));
+ __ci;
+ })->bar;
+}
diff --git a/usr.bin/xlint/lint1/d_gcc_compound_statements3.c b/usr.bin/xlint/lint1/d_gcc_compound_statements3.c
new file mode 100644
index 000000000000..29e9063dcf4a
--- /dev/null
+++ b/usr.bin/xlint/lint1/d_gcc_compound_statements3.c
@@ -0,0 +1,10 @@
+/* GCC compound statements with void type */
+
+void
+main(void)
+{
+ ({
+ void *v;
+ __asm__ volatile("noop");
+ });
+}
diff --git a/usr.bin/xlint/lint1/d_gcc_extension.c b/usr.bin/xlint/lint1/d_gcc_extension.c
new file mode 100644
index 000000000000..d8bd8f5fe944
--- /dev/null
+++ b/usr.bin/xlint/lint1/d_gcc_extension.c
@@ -0,0 +1,6 @@
+/* extension */
+void a(void) {
+ double __logbw = 1;
+ if (__extension__(({ __typeof((__logbw)) x_ = (__logbw); !__builtin_isinf((x_)) && !__builtin_isnan((x_)); })))
+ __logbw = 1;
+}
diff --git a/usr.bin/xlint/lint1/d_gcc_func.c b/usr.bin/xlint/lint1/d_gcc_func.c
new file mode 100644
index 000000000000..459919de2955
--- /dev/null
+++ b/usr.bin/xlint/lint1/d_gcc_func.c
@@ -0,0 +1,7 @@
+/* gcc __FUNCTION__ */
+
+void
+foo(const char *p) {
+ p = __FUNCTION__;
+ foo(p);
+}
diff --git a/usr.bin/xlint/lint1/d_gcc_variable_array_init.c b/usr.bin/xlint/lint1/d_gcc_variable_array_init.c
new file mode 100644
index 000000000000..d5b01ad0c2d2
--- /dev/null
+++ b/usr.bin/xlint/lint1/d_gcc_variable_array_init.c
@@ -0,0 +1,7 @@
+/* gcc: variable array initializer */
+void foo(int i)
+{
+ int array[i];
+ while (i--)
+ foo(array[i] = 0);
+}
diff --git a/usr.bin/xlint/lint1/d_incorrect_array_size.c b/usr.bin/xlint/lint1/d_incorrect_array_size.c
new file mode 100644
index 000000000000..c86c0d6b3b70
--- /dev/null
+++ b/usr.bin/xlint/lint1/d_incorrect_array_size.c
@@ -0,0 +1,3 @@
+struct foo {
+ int a[-1];
+};
diff --git a/usr.bin/xlint/lint1/d_long_double_int.c b/usr.bin/xlint/lint1/d_long_double_int.c
new file mode 100644
index 000000000000..a5a644e3e3d4
--- /dev/null
+++ b/usr.bin/xlint/lint1/d_long_double_int.c
@@ -0,0 +1,7 @@
+/* PR 39639: writing "long double" gave "long int" */
+
+int
+fail(long double *a, long int *b)
+{
+ return a == b;
+}
diff --git a/usr.bin/xlint/lint1/d_nested_structs.c b/usr.bin/xlint/lint1/d_nested_structs.c
new file mode 100644
index 000000000000..edd3396bd224
--- /dev/null
+++ b/usr.bin/xlint/lint1/d_nested_structs.c
@@ -0,0 +1,21 @@
+/* Nested struct */
+typedef void *EditLine;
+typedef void *History;
+
+typedef struct {
+ EditLine *el;
+ History *hist;
+} el_mode_t;
+
+struct el_modes_s {
+ el_mode_t command;
+ el_mode_t string;
+ el_mode_t filec;
+ el_mode_t mime_enc;
+};
+
+struct el_modes_s elm = {
+ .command = { .el = 0, .hist = 0, },
+ .string = { .el = 0, .hist = 0, },
+ .filec = { .el = 0, .hist = 0, },
+};
diff --git a/usr.bin/xlint/lint1/d_nolimit_init.c b/usr.bin/xlint/lint1/d_nolimit_init.c
new file mode 100644
index 000000000000..68e71b4df050
--- /dev/null
+++ b/usr.bin/xlint/lint1/d_nolimit_init.c
@@ -0,0 +1,4 @@
+/* no limit initializers */
+char foo[][4] = {
+ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
+};
diff --git a/usr.bin/xlint/lint1/d_packed_structs.c b/usr.bin/xlint/lint1/d_packed_structs.c
new file mode 100644
index 000000000000..71b438496f92
--- /dev/null
+++ b/usr.bin/xlint/lint1/d_packed_structs.c
@@ -0,0 +1,35 @@
+/* packed tests */
+
+struct in_addr {
+ int x;
+};
+struct ip_timestamp {
+ char ipt_code;
+ char ipt_len;
+ char ipt_ptr;
+ unsigned int ipt_flg:4,
+ ipt_oflw:4;
+ union ipt_timestamp {
+ int ipt_time[1];
+ struct ipt_ta {
+ struct in_addr ipt_addr;
+ int ipt_time;
+ } ipt_ta[1] __packed;
+ } ipt_timestamp __packed;
+} __packed;
+
+typedef struct __packed {
+ int x;
+} t;
+
+struct x {
+ char c;
+ long l;
+} __packed;
+
+struct y {
+ char c;
+ long l;
+};
+
+int a[sizeof(struct y) - sizeof(struct x) - 1];
diff --git a/usr.bin/xlint/lint1/d_shift_to_narrower_type.c b/usr.bin/xlint/lint1/d_shift_to_narrower_type.c
new file mode 100644
index 000000000000..0208944a2d12
--- /dev/null
+++ b/usr.bin/xlint/lint1/d_shift_to_narrower_type.c
@@ -0,0 +1,24 @@
+// Test that type shifts that result to narrower types don't produce warnings.
+
+void
+foo(void) {
+ unsigned long l = 100;
+ unsigned long long ll = 100;
+ unsigned int i = 100;
+ unsigned short s = 100;
+ unsigned char c = 1;
+
+ l = ll >> 32;
+// i = ll >> 31;
+ i = ll >> 32;
+ s = ll >> 48;
+ c = ll >> 56;
+ s = i >> 16;
+ c = i >> 24;
+ c = s >> 8;
+ (void)&ll;
+ (void)&l;
+ (void)&i;
+ (void)&s;
+ (void)&c;
+}
diff --git a/usr.bin/xlint/lint1/d_type_conv1.c b/usr.bin/xlint/lint1/d_type_conv1.c
new file mode 100644
index 000000000000..d9e470e941b9
--- /dev/null
+++ b/usr.bin/xlint/lint1/d_type_conv1.c
@@ -0,0 +1,11 @@
+/* Flag information-losing type conversion in argument lists */
+
+int f(unsigned int);
+
+void
+should_fail()
+{
+ long long x = 20;
+
+ f(x);
+}
diff --git a/usr.bin/xlint/lint1/d_type_conv2.c b/usr.bin/xlint/lint1/d_type_conv2.c
new file mode 100644
index 000000000000..7c2e1f478ecd
--- /dev/null
+++ b/usr.bin/xlint/lint1/d_type_conv2.c
@@ -0,0 +1,11 @@
+/* Flag information-losing type conversion in argument lists */
+
+int f(float);
+
+void
+should_fail()
+{
+ double x = 2.0;
+
+ f(x);
+}
diff --git a/usr.bin/xlint/lint1/d_type_conv3.c b/usr.bin/xlint/lint1/d_type_conv3.c
new file mode 100644
index 000000000000..bc6a8e695ada
--- /dev/null
+++ b/usr.bin/xlint/lint1/d_type_conv3.c
@@ -0,0 +1,10 @@
+/* Flag information-losing type conversion in argument lists */
+
+int f(unsigned int);
+
+void
+should_fail()
+{
+
+ f(0x7fffffffffffffffLL);
+}
diff --git a/usr.bin/xlint/lint1/d_typename_as_var.c b/usr.bin/xlint/lint1/d_typename_as_var.c
new file mode 100644
index 000000000000..248dc7558b52
--- /dev/null
+++ b/usr.bin/xlint/lint1/d_typename_as_var.c
@@ -0,0 +1,14 @@
+typedef char h[10];
+
+typedef struct {
+ int i;
+ char *c;
+} fh;
+
+struct foo {
+ fh h;
+ struct {
+ int x;
+ int y;
+ } fl;
+};
diff --git a/usr.bin/xlint/lint1/d_zero_sized_arrays.c b/usr.bin/xlint/lint1/d_zero_sized_arrays.c
new file mode 100644
index 000000000000..9c06c6b5e413
--- /dev/null
+++ b/usr.bin/xlint/lint1/d_zero_sized_arrays.c
@@ -0,0 +1,3 @@
+struct foo {
+int a[0];
+};
diff --git a/usr.bin/xlint/lint1/t_integration.sh b/usr.bin/xlint/lint1/t_integration.sh
new file mode 100755
index 000000000000..9575f9664d3b
--- /dev/null
+++ b/usr.bin/xlint/lint1/t_integration.sh
@@ -0,0 +1,132 @@
+# $NetBSD: t_integration.sh,v 1.4 2014/04/21 19:10:41 christos Exp $
+#
+# Copyright (c) 2008, 2010 The NetBSD Foundation, Inc.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+
+LINT1=/usr/libexec/lint1
+
+Names=
+
+check_valid()
+{
+ atf_check -s exit:0 ${LINT1} -g -S "$(atf_get_srcdir)/$1" /dev/null
+}
+
+check_invalid()
+{
+ atf_check -s not-exit:0 -o ignore -e ignore ${LINT1} -g -S -w \
+ "$(atf_get_srcdir)/$1" /dev/null
+}
+
+test_case()
+{
+ local result="${1}"; shift
+ local name="${1}"; shift
+ local descr="${*}"
+
+ atf_test_case ${name}
+ eval "${name}_head() {
+ atf_set \"descr\" \"${descr}\";
+ atf_set \"require.progs\" \"${LINT1}\";
+ }"
+ eval "${name}_body() {
+ ${result} d_${name}.c;
+ }"
+
+ Names="${Names} ${name}"
+}
+
+test_case check_valid c99_struct_init "Checks C99 struct initialization"
+test_case check_valid c99_union_init1 "Checks C99 union initialization"
+test_case check_valid c99_union_init2 "Checks C99 union initialization"
+test_case check_valid c99_union_init3 "Checks C99 union initialization"
+test_case check_valid c99_recursive_init "Checks C99 recursive struct/union" \
+ "initialization"
+test_case check_valid c9x_recursive_init "Checks C9X struct/union member" \
+ "init, with nested union and trailing member"
+test_case check_valid nested_structs "Checks nested structs"
+test_case check_valid packed_structs "Checks packed structs"
+
+test_case check_valid cast_init "Checks cast initialization"
+test_case check_valid cast_init2 "Checks cast initialization as the rhs of a" \
+ "- operand"
+test_case check_valid cast_lhs "Checks whether pointer casts are valid lhs" \
+ "lvalues"
+
+test_case check_valid gcc_func "Checks GCC __FUNCTION__"
+test_case check_valid c99_func "Checks C99 __func__"
+
+test_case check_valid gcc_variable_array_init "Checks GCC variable array" \
+ "initializers"
+test_case check_valid c9x_array_init "Checks C9X array initializers"
+test_case check_valid c99_decls_after_stmt "Checks C99 decls after statements"
+test_case check_valid c99_decls_after_stmt3 "Checks C99 decls after statements"
+test_case check_valid nolimit_init "Checks no limit initializers"
+test_case check_valid zero_sized_arrays "Checks zero sized arrays"
+
+test_case check_valid compound_literals1 "Checks compound literals"
+test_case check_valid compound_literals2 "Checks compound literals"
+test_case check_valid gcc_compound_statements1 "Checks GCC compound statements"
+test_case check_valid gcc_compound_statements2 "Checks GCC compound" \
+ "statements with non-expressions"
+test_case check_valid gcc_compound_statements3 "Checks GCC compound" \
+ "statements with void type"
+# XXX: Because of polymorphic __builtin_isnan and expression has null effect
+# test_case check_valid gcc_extension "Checks GCC __extension__ and __typeof__"
+
+test_case check_valid cvt_in_ternary "Checks CVT nodes handling in ?" \
+test_case check_valid cvt_constant "Checks constant conversion"
+test_case check_valid ellipsis_in_switch "Checks ellipsis in switch()"
+test_case check_valid c99_complex_num "Checks C99 complex numbers"
+test_case check_valid c99_complex_split "Checks C99 complex access"
+test_case check_valid c99_for_loops "Checks C99 for loops"
+test_case check_valid alignof "Checks __alignof__"
+test_case check_valid shift_to_narrower_type "Checks that type shifts that" \
+ "result in narrower types do not produce warnings"
+
+test_case check_invalid constant_conv1 "Checks failing on information-losing" \
+ "constant conversion in argument lists"
+test_case check_invalid constant_conv2 "Checks failing on information-losing" \
+ "constant conversion in argument lists"
+
+test_case check_invalid type_conv1 "Checks failing on information-losing" \
+ "type conversion in argument lists"
+test_case check_invalid type_conv2 "Checks failing on information-losing" \
+ "type conversion in argument lists"
+test_case check_invalid type_conv3 "Checks failing on information-losing" \
+ "type conversion in argument lists"
+
+test_case check_invalid incorrect_array_size "Checks failing on incorrect" \
+ "array sizes"
+
+test_case check_invalid long_double_int "Checks for confusion of 'long" \
+ "double' with 'long int'; PR 39639"
+
+atf_init_test_cases()
+{
+ for name in ${Names}; do
+ atf_add_test_case ${name}
+ done
+}