aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/validation
diff options
Diffstat (limited to 'validation')
-rw-r--r--validation/builtin-arith.c31
-rw-r--r--validation/builtin-atomic-clear.c15
-rw-r--r--validation/builtin-sync-fetch.c24
-rw-r--r--validation/crash-undef-in-parens.c9
-rw-r--r--validation/flex-array-nested.c4
-rw-r--r--validation/linear/bitfield-sign-default.c13
-rw-r--r--validation/linear/bitfield-sign-signed.c13
-rw-r--r--validation/linear/bitfield-sign-unsigned.c13
-rw-r--r--validation/linear/bitfield-size.c10
-rw-r--r--validation/optim/bitfield-size.c15
-rw-r--r--validation/optim/bitfield-store-loads.c4
-rw-r--r--validation/optim/sext.c7
-rw-r--r--validation/optim/trunc-or-shl.c6
13 files changed, 124 insertions, 40 deletions
diff --git a/validation/builtin-arith.c b/validation/builtin-arith.c
index d08c93da..3ce59304 100644
--- a/validation/builtin-arith.c
+++ b/validation/builtin-arith.c
@@ -31,22 +31,27 @@ void test(void (*fun)(void))
/*
* check-name: builtin arithmetic
* check-command: sparse -Wno-decl $file
- * check-known-to-fail
*
* check-error-start
-builtin-arith.c:10:xx: error: ...
-builtin-arith.c:11:xx: error: ...
-builtin-arith.c:13:xx: error: arithmetics on pointers to functions
-builtin-arith.c:14:xx: error: arithmetics on pointers to functions
-builtin-arith.c:15:xx: error: arithmetics on pointers to functions
-builtin-arith.c:18:xx: error: ...
-builtin-arith.c:19:xx: error: ...
-builtin-arith.c:21:xx: error: ...
-builtin-arith.c:22:xx: error: ...
-builtin-arith.c:23:xx: error: ...
-builtin-arith.c:24:xx: error: ...
-builtin-arith.c:25:xx: error: ...
+builtin-arith.c:10:14: error: taking the address of built-in function '__builtin_trap'
+builtin-arith.c:11:13: error: taking the address of built-in function '__builtin_trap'
+builtin-arith.c:12:14: error: taking the address of built-in function '__builtin_trap'
+builtin-arith.c:13:14: error: taking the address of built-in function '__builtin_trap'
+builtin-arith.c:13:29: error: arithmetics on pointers to functions
+builtin-arith.c:14:14: error: taking the address of built-in function '__builtin_trap'
+builtin-arith.c:14:29: error: arithmetics on pointers to functions
+builtin-arith.c:15:14: error: taking the address of built-in function '__builtin_trap'
+builtin-arith.c:15:29: error: arithmetics on pointers to functions
+builtin-arith.c:18:21: error: taking the address of built-in function '__builtin_trap'
+builtin-arith.c:19:29: error: taking the address of built-in function '__builtin_trap'
+builtin-arith.c:21:14: error: taking the address of built-in function '__builtin_trap'
+builtin-arith.c:22:14: error: taking the address of built-in function '__builtin_trap'
+builtin-arith.c:23:14: error: taking the address of built-in function '__builtin_trap'
+builtin-arith.c:24:21: error: taking the address of built-in function '__builtin_trap'
+builtin-arith.c:25:21: error: taking the address of built-in function '__builtin_trap'
+builtin-arith.c:27:9: error: taking the address of built-in function '__builtin_trap'
builtin-arith.c:27:24: error: subtraction of functions? Share your drugs
+builtin-arith.c:28:15: error: taking the address of built-in function '__builtin_trap'
builtin-arith.c:28:13: error: subtraction of functions? Share your drugs
* check-error-end
*/
diff --git a/validation/builtin-atomic-clear.c b/validation/builtin-atomic-clear.c
new file mode 100644
index 00000000..ef430c64
--- /dev/null
+++ b/validation/builtin-atomic-clear.c
@@ -0,0 +1,15 @@
+void foo(void *ptr, _Bool *bptr, volatile void *vptr, volatile _Bool *vbptr, int mo)
+{
+ __atomic_clear(ptr, mo);
+ __atomic_clear(bptr, mo);
+ __atomic_clear(vptr, mo);
+ __atomic_clear(vbptr, mo);
+}
+
+/*
+ * check-name: builtin-atomic-clear
+ *
+ * check-error-start
+builtin-atomic-clear.c:1:6: warning: symbol 'foo' was not declared. Should it be static?
+ * check-error-end
+ */
diff --git a/validation/builtin-sync-fetch.c b/validation/builtin-sync-fetch.c
new file mode 100644
index 00000000..45139a3c
--- /dev/null
+++ b/validation/builtin-sync-fetch.c
@@ -0,0 +1,24 @@
+static int ok_int(int *ptr, int val)
+{
+ return __sync_add_and_fetch(ptr, val);
+}
+
+static long* ok_ptr(long **ptr, long *val)
+{
+ return __sync_add_and_fetch(ptr, val);
+}
+
+static void chk_ret_ok(long *ptr, long val)
+{
+ _Static_assert([typeof(__sync_add_and_fetch(ptr, val))] == [long], "");
+}
+
+static int chk_val(int *ptr, long val)
+{
+ // OK: val is converted to an int
+ return __sync_add_and_fetch(ptr, val);
+}
+
+/*
+ * check-name: builtin-sync-fetch
+ */
diff --git a/validation/crash-undef-in-parens.c b/validation/crash-undef-in-parens.c
new file mode 100644
index 00000000..5f05f88a
--- /dev/null
+++ b/validation/crash-undef-in-parens.c
@@ -0,0 +1,9 @@
+void foo(void) { return (UNDEF_STUFF_IN_PARENS); }
+
+/*
+ * check-name: crash-undef-in-parens
+ *
+ * check-error-start
+crash-undef-in-parens.c:1:26: error: undefined identifier 'UNDEF_STUFF_IN_PARENS'
+ * check-error-end
+ */
diff --git a/validation/flex-array-nested.c b/validation/flex-array-nested.c
index a82cbfc9..094de2fb 100644
--- a/validation/flex-array-nested.c
+++ b/validation/flex-array-nested.c
@@ -23,7 +23,7 @@ static int foo(struct s *s, union u *u)
* check-command: sparse -Wflexible-array-nested $file
*
* check-error-start
-flex-array-nested.c:7:18: warning: nested flexible arrays
-flex-array-nested.c:11:18: warning: nested flexible arrays
+flex-array-nested.c:7:18: warning: nested flexible array
+flex-array-nested.c:11:18: warning: nested flexible array
* check-error-end
*/
diff --git a/validation/linear/bitfield-sign-default.c b/validation/linear/bitfield-sign-default.c
new file mode 100644
index 00000000..9a2854e6
--- /dev/null
+++ b/validation/linear/bitfield-sign-default.c
@@ -0,0 +1,13 @@
+struct s {
+ int f:2;
+};
+
+static int getf(struct s s) { return s.f; }
+
+/*
+ * check-name: bitfield-sign-default
+ * check-command: test-linearize -fdump-ir=linearize $file
+ *
+ * check-output-ignore
+ * check-output-contains: sext\\.
+ */
diff --git a/validation/linear/bitfield-sign-signed.c b/validation/linear/bitfield-sign-signed.c
new file mode 100644
index 00000000..59a07ceb
--- /dev/null
+++ b/validation/linear/bitfield-sign-signed.c
@@ -0,0 +1,13 @@
+struct s {
+ int f:2;
+};
+
+static int getf(struct s s) { return s.f; }
+
+/*
+ * check-name: bitfield-sign-signed
+ * check-command: test-linearize -fdump-ir=linearize -fsigned-bitfields $file
+ *
+ * check-output-ignore
+ * check-output-contains: sext\\.
+ */
diff --git a/validation/linear/bitfield-sign-unsigned.c b/validation/linear/bitfield-sign-unsigned.c
new file mode 100644
index 00000000..099edaad
--- /dev/null
+++ b/validation/linear/bitfield-sign-unsigned.c
@@ -0,0 +1,13 @@
+struct s {
+ int f:2;
+};
+
+static int getf(struct s s) { return s.f; }
+
+/*
+ * check-name: bitfield-sign-unsigned
+ * check-command: test-linearize -fdump-ir=linearize -funsigned-bitfields $file
+ *
+ * check-output-ignore
+ * check-output-contains: zext\\.
+ */
diff --git a/validation/linear/bitfield-size.c b/validation/linear/bitfield-size.c
index dcda930d..719b0ab8 100644
--- a/validation/linear/bitfield-size.c
+++ b/validation/linear/bitfield-size.c
@@ -19,7 +19,7 @@ void ucpy(struct u *d, const struct u *s)
struct s {
- int f:3;
+ signed int f:3;
};
int spostinc(struct s *x)
@@ -118,7 +118,7 @@ spostinc:
load.64 %r33 <- 0[x]
load.32 %r34 <- 0[%r33]
trunc.3 %r35 <- (32) %r34
- zext.32 %r36 <- (3) %r35
+ sext.32 %r36 <- (3) %r35
add.32 %r37 <- %r36, $1
trunc.3 %r38 <- (32) %r37
load.32 %r39 <- 0[%r33]
@@ -126,7 +126,7 @@ spostinc:
and.32 %r41 <- %r39, $0xfffffff8
or.32 %r42 <- %r41, %r40
store.32 %r42 -> 0[%r33]
- zext.32 %r43 <- (3) %r36
+ sext.32 %r43 <- (3) %r36
phisrc.32 %phi3(return) <- %r43
br .L7
@@ -142,7 +142,7 @@ spreinc:
load.64 %r45 <- 0[x]
load.32 %r46 <- 0[%r45]
trunc.3 %r47 <- (32) %r46
- zext.32 %r48 <- (3) %r47
+ sext.32 %r48 <- (3) %r47
add.32 %r49 <- %r48, $1
trunc.3 %r50 <- (32) %r49
load.32 %r51 <- 0[%r45]
@@ -150,7 +150,7 @@ spreinc:
and.32 %r53 <- %r51, $0xfffffff8
or.32 %r54 <- %r53, %r52
store.32 %r54 -> 0[%r45]
- zext.32 %r55 <- (3) %r50
+ sext.32 %r55 <- (3) %r50
phisrc.32 %phi4(return) <- %r55
br .L9
diff --git a/validation/optim/bitfield-size.c b/validation/optim/bitfield-size.c
index 0d2deeea..ea1ed57f 100644
--- a/validation/optim/bitfield-size.c
+++ b/validation/optim/bitfield-size.c
@@ -19,17 +19,6 @@ signed int get__bfs_b(struct bfs bf) { return bf.b; }
signed int get_pbfs_a(struct bfs *bf) { return bf->a; }
signed int get_pbfs_b(struct bfs *bf) { return bf->b; }
-
-struct bfi {
- int a:4;
- int :2;
- int b:4;
-};
-unsigned int get__bfi_a(struct bfi bf) { return bf.a; }
-unsigned int get__bfi_b(struct bfi bf) { return bf.b; }
-unsigned int get_pbfi_a(struct bfi *bf) { return bf->a; }
-unsigned int get_pbfi_b(struct bfi *bf) { return bf->b; }
-
/*
* check-name: bitfield size
* check-command: test-linearize -Wno-decl $file
@@ -37,8 +26,8 @@ unsigned int get_pbfi_b(struct bfi *bf) { return bf->b; }
*
* check-output-excludes: and\\..*\\$960
* check-output-excludes: zext\\.
- * check-output-pattern(8): and\\..*\\$15
+ * check-output-pattern(4): and\\..*\\$15
* check-output-pattern(4): sext\\.
* check-output-pattern(4): trunc\\.4
- * check-output-pattern(6): lsr\\..*\\$6
+ * check-output-pattern(4): lsr\\..*\\$6
*/
diff --git a/validation/optim/bitfield-store-loads.c b/validation/optim/bitfield-store-loads.c
index dc625131..f946715b 100644
--- a/validation/optim/bitfield-store-loads.c
+++ b/validation/optim/bitfield-store-loads.c
@@ -1,6 +1,6 @@
struct s {
- char :2;
- char f:3;
+ unsigned char :2;
+ unsigned char f:3;
};
int foo(struct s s, int a)
diff --git a/validation/optim/sext.c b/validation/optim/sext.c
index 719730d5..3769a05c 100644
--- a/validation/optim/sext.c
+++ b/validation/optim/sext.c
@@ -6,10 +6,9 @@ int sext(int x)
/*
* check-name: sext
* check-command: test-linearize -Wno-decl $file
- * check-known-to-fail
*
* check-output-ignore
- * check-output-contains: sext\\.$27
- * check-output-excludes: asr\\.
- * check-output-excludes: shl\\.
+ * check-output-excludes: sext\\.
+ * check-output-contains: asr\\.32
+ * check-output-contains: shl\\.32
*/
diff --git a/validation/optim/trunc-or-shl.c b/validation/optim/trunc-or-shl.c
index 70d8bd1d..8660d0f0 100644
--- a/validation/optim/trunc-or-shl.c
+++ b/validation/optim/trunc-or-shl.c
@@ -1,3 +1,6 @@
+// because of the cast to char, the fist arg should be eliminated
+// and the whole reduced to TRUNC(%arg2, 8)
+
char foo(int a, int b)
{
return (a << 8) | b;
@@ -9,5 +12,6 @@ char foo(int a, int b)
* check-known-to-fail
*
* check-output-ignore
- * check-output-contains: ret\\..*%arg2
+ * check-output-excludes: %arg1
+ * check-output-contains: trunc\\..*%arg2
*/