aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2020-12-11 02:58:48 +0100
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2020-12-11 02:58:48 +0100
commit72edf4380a05f7dd7f3ff19cf6b32c125028ab26 (patch)
tree72b6187f37bc57769e16c3e5b31dc3de45fe56bf
parentd08e3d0b695063a26e999e5188066f8eabf2c25a (diff)
parent7a9da618ba96a30e8a09543cac030c4d44b829a7 (diff)
downloadsparse-72edf4380a05f7dd7f3ff19cf6b32c125028ab26.tar.gz
Merge branches 'kill-asm' and 'next'
* fix killing OP_ASM * move check_access() to late_warnings()
-rw-r--r--linearize.c6
-rw-r--r--memops.c3
-rw-r--r--validation/bad-check-access0.c31
3 files changed, 37 insertions, 3 deletions
diff --git a/linearize.c b/linearize.c
index 9fecb4b5..0250c6bb 100644
--- a/linearize.c
+++ b/linearize.c
@@ -2532,6 +2532,12 @@ static void late_warnings(struct entrypoint *ep)
continue;
if (insn->tainted)
check_tainted_insn(insn);
+ switch (insn->opcode) {
+ case OP_LOAD:
+ // Check for illegal offsets.
+ check_access(insn);
+ break;
+ }
} END_FOR_EACH_PTR(insn);
} END_FOR_EACH_PTR(bb);
}
diff --git a/memops.c b/memops.c
index d96bd8a9..0a1106b0 100644
--- a/memops.c
+++ b/memops.c
@@ -147,9 +147,6 @@ static void simplify_loads(struct basic_block *bb)
struct pseudo_list *dominators;
unsigned long generation;
- /* Check for illegal offsets.. */
- check_access(insn);
-
if (insn->is_volatile)
continue;
diff --git a/validation/bad-check-access0.c b/validation/bad-check-access0.c
new file mode 100644
index 00000000..3c4c023f
--- /dev/null
+++ b/validation/bad-check-access0.c
@@ -0,0 +1,31 @@
+#define SIZE 2
+static int buf[SIZE];
+
+static inline int swt(int i)
+{
+ switch (i) {
+ case 0 ... (SIZE-1):
+ return buf[i];
+ default:
+ return 0;
+ }
+}
+
+static int switch_ok(void) { return swt(1); }
+static int switch_ko(void) { return swt(2); }
+
+
+static inline int cbr(int i, int p)
+{
+ if (p)
+ return buf[i];
+ else
+ return 0;
+}
+
+static int branch_ok(int x) { return cbr(1, x != x); }
+static int branch_ko(int x) { return cbr(2, x != x); }
+
+/*
+ * check-name: bad-check-access0
+ */