Skip to content
Snippets Groups Projects
Commit dd14b08e authored by Jakub Jelinek's avatar Jakub Jelinek Committed by Jakub Jelinek
Browse files

c++: Fix weird expression in test for clauses other than when/default/otherwise [PR118604]

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.

2025-01-23  Jakub Jelinek  <jakub@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.
parent d19b0682
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment