opnemp: add static assert for clause_names.
authorMartin Liska <mliska@suse.cz>
Mon, 17 Aug 2020 09:14:13 +0000 (11:14 +0200)
committerMartin Liska <mliska@suse.cz>
Mon, 17 Aug 2020 11:57:55 +0000 (13:57 +0200)
gcc/fortran/ChangeLog:

* openmp.c (resolve_omp_clauses): Add static assert
for OMP_LIST_NUM and size of clause_names array.
Remove check that is always true.

gcc/fortran/openmp.c

index 60d8e5573c219e5df316dc038fac48609b1f61ec..4d33a450a33d04c0080899de21004ce1ce0b624d 100644 (file)
@@ -4371,6 +4371,7 @@ resolve_omp_clauses (gfc_code *code, gfc_omp_clauses *omp_clauses,
        "TO", "FROM", "REDUCTION", "DEVICE_RESIDENT", "LINK", "USE_DEVICE",
        "CACHE", "IS_DEVICE_PTR", "USE_DEVICE_PTR", "USE_DEVICE_ADDR",
        "NONTEMPORAL" };
+  STATIC_ASSERT (ARRAY_SIZE (clause_names) == OMP_LIST_NUM);
 
   if (omp_clauses == NULL)
     return;
@@ -4732,12 +4733,7 @@ resolve_omp_clauses (gfc_code *code, gfc_omp_clauses *omp_clauses,
   for (list = 0; list < OMP_LIST_NUM; list++)
     if ((n = omp_clauses->lists[list]) != NULL)
       {
-       const char *name;
-
-       if (list < OMP_LIST_NUM)
-         name = clause_names[list];
-       else
-         gcc_unreachable ();
+       const char *name = clause_names[list];
 
        switch (list)
          {