From 837b9622fbf0f957fefbfa33cea8b1700952ba95 Mon Sep 17 00:00:00 2001 From: David Given Date: Sat, 7 Jan 2017 19:53:57 +0100 Subject: [PATCH] Make sure that constant folding doesn't render our tests trivial. --- tests/plat/b/incdec_b.b | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/tests/plat/b/incdec_b.b b/tests/plat/b/incdec_b.b index b3cb16da5..4edf5f6bf 100644 --- a/tests/plat/b/incdec_b.b +++ b/tests/plat/b/incdec_b.b @@ -1,65 +1,70 @@ # +/* External variables to defeat constant folding. */ +zero 0; +one 1; + i 0; ext_t() { - extrn i; + extrn zero, one, i; - i = 0; + i = zero; if (!(i++ == 0)) fail(__LINE__); - i == 1; + i = one; if (!(i-- == 1)) fail(__LINE__); if (!(i == 0)) fail(__LINE__); - i = 0; + i = zero; if (!(++i == 1)) fail(__LINE__); if (!(i == 1)) fail(__LINE__); - i == 1; + i = one; if (!(--i == 0)) fail(__LINE__); if (!(i == 0)) fail(__LINE__); } int_t() { - auto i; + extrn zero, one; + auto i; - i = 0; + i = zero; if (!(i++ == 0)) fail(__LINE__); - i == 1; + i = one; if (!(i-- == 1)) fail(__LINE__); if (!(i == 0)) fail(__LINE__); - i = 0; + i = zero; if (!(++i == 1)) fail(__LINE__); if (!(i == 1)) fail(__LINE__); - i == 1; + i = one; if (!(--i == 0)) fail(__LINE__); if (!(i == 0)) fail(__LINE__); } star_t() { - extrn i; + extrn zero, one, i; auto p; p = &i; - i = 0; + i = zero; if (!((*p)++ == 0)) fail(__LINE__); - i == 1; + i = one; if (!((*p)-- == 1)) fail(__LINE__); if (!(i == 0)) fail(__LINE__); - i = 0; + i = zero; if (!(++(*p) == 1)) fail(__LINE__); if (!(i == 1)) fail(__LINE__); - i == 1; + i = one; if (!(--(*p) == 0)) fail(__LINE__); if (!(i == 0)) fail(__LINE__); }