diff options
| author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2018-07-31 15:00:06 +0200 |
|---|---|---|
| committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2018-08-06 08:50:40 +0200 |
| commit | 3334fa789234c05da18b9e0e284bc04e5ef6b39b (patch) | |
| tree | 830a09a4ce171452bab3fc9da5778c86048021eb /validation | |
| parent | 875235a6801d1c5a9ccc9c265fe45a8f6a0f87c0 (diff) | |
| download | sparse-dev-3334fa789234c05da18b9e0e284bc04e5ef6b39b.tar.gz | |
fix linearize_conditional() for logical ops
The function linearize_conditional(), normaly used for conditionals
(c ? a : b) is also used to linearize the logical ops || and &&.
For conditionals, the type evaluation ensure that both LHS & RHS
have consistent types. However, this is not the case when used for
logical ops. This creates 2 separated but related problems:
* the operands are not compared with 0 as required by the standard
(6.5.13, 6.5.14).
* both operands can have different, incompatible types and thus
it's possible to have a phi-node with sources of different,
incompatible types, which doesn't make sense.
Fix this by:
* add a flag to linearize_conditional() telling if it's used for
a conditional or for a logical op.
* when used for logical ops:
* first compare the operands againts zero
* convert the boolean result to the expression's type.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Diffstat (limited to 'validation')
| -rw-r--r-- | validation/linear/logical.c | 1 |
1 files changed, 0 insertions, 1 deletions
diff --git a/validation/linear/logical.c b/validation/linear/logical.c index 645adc56..972f8709 100644 --- a/validation/linear/logical.c +++ b/validation/linear/logical.c @@ -19,7 +19,6 @@ int ad(int i, struct S *b) { return i && b->d; } /* * check-name: logical * check-command: test-linearize -m64 -fdump-ir -Wno-decl $file - * check-known-to-fail * * check-output-start os: |
