On Fri, Aug 9, 2024 at 12:39 AM Jakub Jelinek <ja...@redhat.com> wrote: > > Hi! > > These two spots were just non-standard, because they divided > sizeof (omp_pragmas_simd) by sizeof (*omp_pragmas) and not > the expected sizeof (*omp_pragmas_simd) and so weren't converted > into ARRAY_SIZE. Both of the latter sizes are the same though, > as both arrays have the same type, so this patch doesn't change > anything but readability. > > Bootstrapped/regtested on x86_64-linux and i686-linux, committed > to trunk. > > 2024-08-09 Jakub Jelinek <ja...@redhat.com> > > * c-pragma.cc (c_pp_lookup_pragma): Use ARRAY_SIZE in > n_omp_pragmas_simd initializer.
I noticed the loops in c_pp_lookup_pragma could be candidates to use C++11 range based for loops instead of using ARRAY_SIZE. > (init_pragmas): Likewise. Likewise here too. Definitely less error prone than using ARRAY_SIZE even. Thanks, Andrew > > --- gcc/c-family/c-pragma.cc.jj 2024-06-05 19:09:54.054616902 +0200 > +++ gcc/c-family/c-pragma.cc 2024-08-09 00:44:58.913489987 +0200 > @@ -1565,8 +1565,7 @@ c_pp_lookup_pragma (unsigned int id, con > { > const int n_oacc_pragmas = ARRAY_SIZE (oacc_pragmas); > const int n_omp_pragmas = ARRAY_SIZE (omp_pragmas); > - const int n_omp_pragmas_simd = sizeof (omp_pragmas_simd) > - / sizeof (*omp_pragmas); > + const int n_omp_pragmas_simd = ARRAY_SIZE (omp_pragmas_simd); > int i; > > for (i = 0; i < n_oacc_pragmas; ++i) > @@ -1807,8 +1806,7 @@ init_pragma (void) > } > if (flag_openmp || flag_openmp_simd) > { > - const int n_omp_pragmas_simd > - = sizeof (omp_pragmas_simd) / sizeof (*omp_pragmas); > + const int n_omp_pragmas_simd = ARRAY_SIZE (omp_pragmas_simd); > int i; > > for (i = 0; i < n_omp_pragmas_simd; ++i) > > Jakub >