diff mbox series

[committed] fortran/openmp.c - silence static analyzer warning (was: [Patch] OpenMP: Fixes for omp critical + hint)

Message ID 49b5dbcf-ccde-2e0c-fd47-ab9b87f6285c@codesourcery.com
State New
Headers show
Series [committed] fortran/openmp.c - silence static analyzer warning (was: [Patch] OpenMP: Fixes for omp critical + hint) | expand

Commit Message

Tobias Burnus July 27, 2020, 7:36 a.m. UTC
As complained by Coverity, which was pointed out to my
by Fredering (thanks!), that patch lead to an inconsistency:

+      if (code->ext.omp_clauses)
+       resolve_omp_clauses (code, code->ext.omp_clauses, NULL);
+      if (!code->ext.omp_clauses->critical_name

Before, we had:
   !$omp critical [(name) [hint()]]
but as for hint == 0 '(name)' is not required, we now have:
   !$omp critical [(name)] [hint()]
Result: gfc_match_omp_clauses is now called unconditionally
and (unless MATCH_ERROR) it always allocates 'ext.omp_clauses'.

Thus, we can now remove first condition – which caused that
Coverity's scanner assumed that the second condition
could dereference a NULL pointer in the 'false' case.

Committed as obvious.

Tobias


-----------------
Mentor Graphics (Deutschland) GmbH, Arnulfstraße 201, 80634 München / Germany
Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Alexander Walter
diff mbox series

Patch

commit 20d0d6527c36005a9664f7ac9eb50f1071d5670c
Author: Tobias Burnus <tobias@codesourcery.com>
Date:   Mon Jul 27 09:12:15 2020 +0200

    fortran/openmp.c - silence static analyzer warning
    
    gcc/fortran/ChangeLog:
    
            * openmp.c (gfc_resolve_omp_directive): Remove NULL check
            for clauses in EXEC_OMP_CRITICAL as it no longer can be NULL.

diff --git a/gcc/fortran/openmp.c b/gcc/fortran/openmp.c
index f8f2439b6e4..4a0466f968d 100644
--- a/gcc/fortran/openmp.c
+++ b/gcc/fortran/openmp.c
@@ -6560,8 +6560,7 @@  gfc_resolve_omp_directive (gfc_code *code, gfc_namespace *ns ATTRIBUTE_UNUSED)
       resolve_omp_atomic (code);
       break;
     case EXEC_OMP_CRITICAL:
-      if (code->ext.omp_clauses)
-	resolve_omp_clauses (code, code->ext.omp_clauses, NULL);
+      resolve_omp_clauses (code, code->ext.omp_clauses, NULL);
       if (!code->ext.omp_clauses->critical_name
 	  && code->ext.omp_clauses->hint
 	  && code->ext.omp_clauses->hint->ts.type == BT_INTEGER