I intent to commit this a bit later today as obvious, unless there are comments.
This is about two functions unconditionally return 'true'. Both appear (also) in an 'if' condition that is pointless. (The second one also appears in two other calls without an 'if', so far for consistency.) Besides making the code less readable and a tad slower, one 'if' clause also lead to a Clang warning - as the variable is only initialized in the 'true' case. Thanks to David for reporting, to Xi for a first analysis and to Kaaden for writing RFC patches in the PR. Tobias
omp-general.cc: Remove 'if' around call to always 'true' returning function [PR118627] Before omp_parse_access_method and omp_parse_access_methods unconditionally returned true, now they are void functions. Accordingly, calls had to be updated by removing the 'if' around the call; this also fixes Clang's -Wsometimes-uninitialized warning when compiling omp-general.cc as one variable remained uninitialized for a never occurring false. gcc/ChangeLog: PR middle-end/118627 * omp-general.cc (omp_parse_access_method): Change to return void. (omp_parse_access_methods): Return void; remove 'if' around a function call. (omp_parse_expr): Remove 'if' around a function call. gcc/omp-general.cc | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/gcc/omp-general.cc b/gcc/omp-general.cc index 0a2dd6b5be7..0b7c3b9d318 100644 --- a/gcc/omp-general.cc +++ b/gcc/omp-general.cc @@ -4183,11 +4183,11 @@ omp_parse_pointer (tree *expr0, bool *has_offset) } return false; } -static bool +static void omp_parse_access_method (tree *expr0, enum access_method_kinds *kind) { tree expr = *expr0; bool has_offset; @@ -4214,32 +4214,30 @@ omp_parse_access_method (tree *expr0, enum access_method_kinds *kind) *kind = ACCESS_DIRECT; STRIP_NOPS (expr); *expr0 = expr; - return true; } -static bool +static void omp_parse_access_methods (vec<omp_addr_token *> &addr_tokens, tree *expr0) { tree expr = *expr0; enum access_method_kinds kind; tree am_expr; - if (omp_parse_access_method (&expr, &kind)) - am_expr = expr; + omp_parse_access_method (&expr, &kind); + am_expr = expr; if (TREE_CODE (expr) == INDIRECT_REF || TREE_CODE (expr) == MEM_REF || TREE_CODE (expr) == ARRAY_REF) omp_parse_access_methods (addr_tokens, &expr); addr_tokens.safe_push (new omp_addr_token (kind, am_expr)); *expr0 = expr; - return true; } static bool omp_parse_structured_expr (vec<omp_addr_token *> &, tree *); static bool @@ -4353,12 +4351,11 @@ bool omp_parse_expr (vec<omp_addr_token *> &addr_tokens, tree expr) { using namespace omp_addr_tokenizer; auto_vec<omp_addr_token *> expr_access_tokens; - if (!omp_parse_access_methods (expr_access_tokens, &expr)) - return false; + omp_parse_access_methods (expr_access_tokens, &expr); if (omp_parse_structured_expr (addr_tokens, &expr)) ; else if (omp_parse_array_expr (addr_tokens, &expr)) ;