summaryrefslogtreecommitdiffstats
path: root/contrib/netbsd-tests/usr.bin/xlint/lint1
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/netbsd-tests/usr.bin/xlint/lint1')
-rw-r--r--contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_anon_struct.c26
-rw-r--r--contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_anon_union.c16
-rw-r--r--contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_compound_literal_comma.c14
-rw-r--r--contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_flex_array_packed.c6
-rw-r--r--contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_nested_struct.c25
-rw-r--r--contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_union_cast.c18
-rw-r--r--contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_union_init4.c15
-rw-r--r--contrib/netbsd-tests/usr.bin/xlint/lint1/d_cast_fun_array_param.c9
-rw-r--r--contrib/netbsd-tests/usr.bin/xlint/lint1/d_type_question_colon.c14
-rw-r--r--contrib/netbsd-tests/usr.bin/xlint/lint1/d_typefun.c22
10 files changed, 165 insertions, 0 deletions
diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_anon_struct.c b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_anon_struct.c
new file mode 100644
index 0000000..367b56f
--- /dev/null
+++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_anon_struct.c
@@ -0,0 +1,26 @@
+/* Anonymous struct test */
+
+typedef int type;
+
+struct point {
+ int x;
+ int y;
+};
+
+struct bar {
+ struct {
+ struct point top_left;
+ struct point bottom_right;
+ };
+ type z;
+};
+
+
+int
+main(void)
+{
+ struct bar b;
+ b.top_left.x = 1;
+ return 0;
+}
+
diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_anon_union.c b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_anon_union.c
new file mode 100644
index 0000000..508bcc9
--- /dev/null
+++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_anon_union.c
@@ -0,0 +1,16 @@
+/* struct with only anonymous members */
+
+struct foo {
+ union {
+ long loo;
+ double doo;
+ };
+};
+
+int
+main(void) {
+
+ struct foo *f = 0;
+ printf("%p\n", &f[1]);
+ return 0;
+}
diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_compound_literal_comma.c b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_compound_literal_comma.c
new file mode 100644
index 0000000..ca70694
--- /dev/null
+++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_compound_literal_comma.c
@@ -0,0 +1,14 @@
+struct bintime {
+ unsigned long long sec;
+ unsigned long long frac;
+};
+
+struct bintime
+us2bintime(unsigned long long us)
+{
+
+ return (struct bintime) {
+ .sec = us / 1000000U,
+ .frac = (((us % 1000000U) >> 32)/1000000U) >> 32,
+ };
+}
diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_flex_array_packed.c b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_flex_array_packed.c
new file mode 100644
index 0000000..e7b8756
--- /dev/null
+++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_flex_array_packed.c
@@ -0,0 +1,6 @@
+/* Allow packed c99 flexible arrays */
+struct {
+ int x;
+ char y[0];
+} __packed foo;
+
diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_nested_struct.c b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_nested_struct.c
new file mode 100644
index 0000000..15410c8
--- /dev/null
+++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_nested_struct.c
@@ -0,0 +1,25 @@
+/* C99 nested struct init with named and non-named initializers */
+typedef struct pthread_mutex_t {
+ unsigned int ptm_magic;
+ char ptm_errorcheck;
+
+ char ptm_pad1[3];
+
+ char ptm_interlock;
+
+ char ptm_pad2[3];
+
+ volatile void * ptm_owner;
+ void * volatile ptm_waiters;
+ unsigned int ptm_recursed;
+ void *ptm_spare2;
+} pthread_mutex_t;
+
+
+struct arc4random_global {
+
+ pthread_mutex_t lock;
+} arc4random_global = {
+
+ .lock = { 0x33330003, 0, { 0, 0, 0 }, 0, { 0, 0, 0 }, ((void *)0), ((void *)0), 0, ((void *)0) },
+};
diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_union_cast.c b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_union_cast.c
new file mode 100644
index 0000000..31628b4
--- /dev/null
+++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_union_cast.c
@@ -0,0 +1,18 @@
+/* union cast */
+
+struct bar {
+ int a;
+ int b;
+};
+
+union foo {
+ struct bar *a;
+ int b;
+};
+
+void
+foo(void) {
+ struct bar *a;
+
+ ((union foo)a).a;
+}
diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_union_init4.c b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_union_init4.c
new file mode 100644
index 0000000..f73b113
--- /dev/null
+++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_union_init4.c
@@ -0,0 +1,15 @@
+/* test .data.l[x] */
+typedef struct {
+ int type;
+ union {
+ char b[20];
+ short s[10];
+ long l[5];
+ } data;
+} foo;
+
+
+foo bar = {
+ .type = 3,
+ .data.l[0] = 4
+};
diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/d_cast_fun_array_param.c b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_cast_fun_array_param.c
new file mode 100644
index 0000000..345c783
--- /dev/null
+++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_cast_fun_array_param.c
@@ -0,0 +1,9 @@
+
+static void f(void *b[4]) {
+ (void)&b;
+}
+
+void *
+foo(void *fn) {
+ return fn == 0 ? f : (void (*)(void *[4])) fn;
+}
diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/d_type_question_colon.c b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_type_question_colon.c
new file mode 100644
index 0000000..00f69cd
--- /dev/null
+++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_type_question_colon.c
@@ -0,0 +1,14 @@
+/* the type of the ?: expression should be the more specific type */
+
+struct foo {
+ int bar;
+};
+
+void
+test(void) {
+ int i;
+ struct foo *ptr = 0;
+
+ for (i = (ptr ? ptr : (void *)0)->bar; i < 10; i++)
+ test();
+}
diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/d_typefun.c b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_typefun.c
new file mode 100644
index 0000000..ad69c51
--- /dev/null
+++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_typefun.c
@@ -0,0 +1,22 @@
+/* typedef of function parameter */
+
+typedef void (*free_func) (void * opaque, void* address);
+typedef struct stack_st
+{
+ int num;
+ char **data;
+ int sorted;
+
+ int num_alloc;
+ int (*comp)(const void *, const void *);
+} _STACK; /* Use STACK_OF(...) instead */
+
+typedef void *OPENSSL_BLOCK;
+struct stack_st_OPENSSL_BLOCK { _STACK stack; };
+typedef void *d2i_of_void(void **,const unsigned char **,long); typedef int i2d_of_void(void *,unsigned char **);
+
+struct stack_st_OPENSSL_BLOCK *d2i_ASN1_SET(struct stack_st_OPENSSL_BLOCK **a,
+ const unsigned char **pp,
+ long length, d2i_of_void *d2i,
+ void (*free_func)(OPENSSL_BLOCK), int ex_tag,
+ int ex_class);
OpenPOWER on IntegriCloud