mycoboco / beluga

a standard C compiler (with an integrated preprocessor)
http://code.woong.org/beluga
Other
65 stars 8 forks source link

incorrect range highlight on unused value of conditional expression #92

Closed mycoboco closed 7 years ago

mycoboco commented 7 years ago
void f(void)
{
    int x;

    (0)? x: x;
}

gives

foo.c:5:5: warning - expression result not used
      (0)? x: x;
      ^~~
mycoboco commented 7 years ago

Fixing to highlight the whole conditional expression with pin-pointing sub-expressions that are not used makes the code much more complicated than expected; it requires an additional parameter to tree_chkused() to denote a dry-run and a distinguished return value to signal that only one operand has no side effect on a dry-run.

Highlighting a sub-expression seems to be a good compromise considering other product compilers.