Hi! Some clang analyzer warned about if (!strcmp (p, "when") == 0 && !default_p) which really looks weird, it is better to use strcmp (p, "when") != 0 or !!strcmp (p, "when"). Furthermore, as a micro optimization, it is cheaper to evaluate default_p than calling strcmp, so that can be put first in the &&.
The C test for the same thing wasn't that weird, but I think for consistency it is better to use the same test rather than trying to be creative. Bootstrapped/regtested on x86_64-linux and i686-linux, committed to trunk. 2025-01-23 Jakub Jelinek <ja...@redhat.com> PR c++/118604 gcc/c/ * c-parser.cc (c_parser_omp_metadirective): Rewrite condition for clauses other than when, default and otherwise. gcc/cp/ * parser.cc (cp_parser_omp_metadirective): Test !default_p first and use strcmp () != 0 rather than !strcmp () == 0. --- gcc/c/c-parser.cc.jj 2025-01-17 11:29:33.318693861 +0100 +++ gcc/c/c-parser.cc 2025-01-22 12:11:47.815133179 +0100 @@ -29069,7 +29069,7 @@ c_parser_omp_metadirective (c_parser *pa c_parser_skip_to_end_of_block_or_statement (parser, true); goto error; } - if (!(strcmp (p, "when") == 0 || default_p)) + if (!default_p && strcmp (p, "when") != 0) { error_at (match_loc, "%qs is not valid for %qs", p, "metadirective"); --- gcc/cp/parser.cc.jj 2025-01-22 09:24:31.102607407 +0100 +++ gcc/cp/parser.cc 2025-01-22 12:08:32.700901589 +0100 @@ -51314,7 +51314,7 @@ cp_parser_omp_metadirective (cp_parser * cp_parser_skip_to_end_of_block_or_statement (parser, true); goto fail; } - if (!strcmp (p, "when") == 0 && !default_p) + if (!default_p && strcmp (p, "when") != 0) { error_at (match_loc, "%qs is not valid for %qs", p, "metadirective"); Jakub