Bug 102726 - Does not warn for enum constant in boolean context
Summary: Does not warn for enum constant in boolean context
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 12.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
Keywords: diagnostic
Depends on:
Blocks: new-warning, new_warning
  Show dependency treegraph
Reported: 2021-10-13 11:37 UTC by Richard Biener
Modified: 2021-10-13 17:42 UTC (History)
4 users (show)

See Also:
Known to work:
Known to fail:
Last reconfirmed: 2021-10-13 00:00:00


Note You need to log in before you can comment on or make changes to this bug.
Description Richard Biener 2021-10-13 11:37:19 UTC
We fail to warn for

                           gsi_replace (&gsi, call, GSI_SAME_STMT);


extern bool gsi_replace (gimple_stmt_iterator *, gimple *, bool);


enum gsi_iterator_update
  GSI_NEW_STMT,         /* Move the iterator to the first statement added.  */
  GSI_SAME_STMT,        /* Leave the iterator at the same statement.  */
  GSI_CONTINUE_LINKING  /* Move iterator to whatever position is suitable
                           for linking other statements in the same
                           direction.  */

presumably because GSI_SAME_STMT is 1
Comment 1 Martin Sebor 2021-10-13 15:24:54 UTC
Confirmed with the test case below:

$ cat pr102726.C && gcc -S -Wall pr102726.C 
void f (bool);

enum { E0, E1, E2 };

void f (void)
  f (E0);        // missing warning
  f (E1);        // missing warning
  f (E2);        // -Wint-in-bool-context

pr102726.C: In function ‘void f()’:
pr102726.C:9:6: warning: enum constant in boolean context [-Wint-in-bool-context]
    9 |   f (E2);        // -Wint-in-bool-context
      |      ^~