summaryrefslogtreecommitdiff
path: root/gcc/c-family
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/c-family')
-rw-r--r--gcc/c-family/c-attribs.cc3
-rw-r--r--gcc/c-family/c-common.cc7
-rw-r--r--gcc/c-family/c-format.cc12
-rw-r--r--gcc/c-family/c-pragma.cc9
-rw-r--r--gcc/c-family/known-headers.cc5
5 files changed, 15 insertions, 21 deletions
diff --git a/gcc/c-family/c-attribs.cc b/gcc/c-family/c-attribs.cc
index 0f047a105c2..e50e79e0cd1 100644
--- a/gcc/c-family/c-attribs.cc
+++ b/gcc/c-family/c-attribs.cc
@@ -4952,8 +4952,7 @@ handle_access_attribute (tree node[3], tree name, tree args, int flags,
int imode;
{
- const int nmodes =
- sizeof attr_access::mode_names / sizeof *attr_access::mode_names;
+ const int nmodes = ARRAY_SIZE (attr_access::mode_names);
for (imode = 0; imode != nmodes; ++imode)
if (!strncmp (ps, attr_access::mode_names[imode],
diff --git a/gcc/c-family/c-common.cc b/gcc/c-family/c-common.cc
index 6156e5fcb0c..c9c9e720bc8 100644
--- a/gcc/c-family/c-common.cc
+++ b/gcc/c-family/c-common.cc
@@ -602,8 +602,7 @@ const struct c_common_resword c_common_reswords[] =
{ "null_resettable", RID_NULL_RESETTABLE, D_OBJC },
};
-const unsigned int num_c_common_reswords =
- sizeof c_common_reswords / sizeof (struct c_common_resword);
+const unsigned int num_c_common_reswords = ARRAY_SIZE (c_common_reswords);
/* Return identifier for address space AS. */
@@ -4482,9 +4481,7 @@ c_common_nodes_and_builtins (void)
/* Make fileptr_type_node a distinct void * type until
FILE type is defined. Likewise for const struct tm*. */
- for (unsigned i = 0;
- i < sizeof (builtin_structptr_types) / sizeof (builtin_structptr_type);
- ++i)
+ for (unsigned i = 0; i < ARRAY_SIZE (builtin_structptr_types); ++i)
builtin_structptr_types[i].node
= build_variant_type_copy (builtin_structptr_types[i].base);
diff --git a/gcc/c-family/c-format.cc b/gcc/c-family/c-format.cc
index ea57fde801c..25b1c1d0f15 100644
--- a/gcc/c-family/c-format.cc
+++ b/gcc/c-family/c-format.cc
@@ -3189,7 +3189,7 @@ check_tokens (const token_t *tokens, unsigned ntoks,
else
{
/* Diagnose some common misspellings. */
- for (unsigned i = 0; i != sizeof badwords / sizeof *badwords; ++i)
+ for (unsigned i = 0; i != ARRAY_SIZE (badwords); ++i)
{
unsigned badwlen = strspn (badwords[i].name, " -");
if (wlen >= badwlen
@@ -3384,14 +3384,14 @@ check_plain (location_t format_string_loc, tree format_string_cst,
if (ISPUNCT (format_chars[0]))
{
- size_t nelts = sizeof c_opers / sizeof *c_opers;
+ size_t nelts = ARRAY_SIZE (c_opers);
if (const char *ret = check_tokens (c_opers, nelts,
format_string_loc, format_string_cst,
orig_format_chars, format_chars,
baltoks))
return ret;
- nelts = c_dialect_cxx () ? sizeof cxx_opers / sizeof *cxx_opers : 0;
+ nelts = c_dialect_cxx () ? ARRAY_SIZE (cxx_opers) : 0;
if (const char *ret = check_tokens (cxx_opers, nelts,
format_string_loc, format_string_cst,
orig_format_chars, format_chars,
@@ -3401,14 +3401,14 @@ check_plain (location_t format_string_loc, tree format_string_cst,
if (ISALPHA (format_chars[0]))
{
- size_t nelts = sizeof c_keywords / sizeof *c_keywords;
+ size_t nelts = ARRAY_SIZE (c_keywords);
if (const char *ret = check_tokens (c_keywords, nelts,
format_string_loc, format_string_cst,
orig_format_chars, format_chars,
baltoks))
return ret;
- nelts = c_dialect_cxx () ? sizeof cxx_keywords / sizeof *cxx_keywords : 0;
+ nelts = c_dialect_cxx () ? ARRAY_SIZE (cxx_keywords) : 0;
if (const char *ret = check_tokens (cxx_keywords, nelts,
format_string_loc, format_string_cst,
orig_format_chars, format_chars,
@@ -3527,7 +3527,7 @@ check_plain (location_t format_string_loc, tree format_string_cst,
&& ISALPHA (format_chars[1]))
{
/* Diagnose a subset of contractions that are best avoided. */
- for (unsigned i = 0; i != sizeof contrs / sizeof *contrs; ++i)
+ for (unsigned i = 0; i != ARRAY_SIZE (contrs); ++i)
{
const char *apos = strchr (contrs[i].name, '\'');
gcc_assert (apos != NULL);
diff --git a/gcc/c-family/c-pragma.cc b/gcc/c-family/c-pragma.cc
index 4c80bdd26d6..cc05b2580fa 100644
--- a/gcc/c-family/c-pragma.cc
+++ b/gcc/c-family/c-pragma.cc
@@ -1400,8 +1400,8 @@ static const struct omp_pragma_def omp_pragmas_simd[] = {
void
c_pp_lookup_pragma (unsigned int id, const char **space, const char **name)
{
- const int n_oacc_pragmas = sizeof (oacc_pragmas) / sizeof (*oacc_pragmas);
- const int n_omp_pragmas = sizeof (omp_pragmas) / sizeof (*omp_pragmas);
+ 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);
int i;
@@ -1576,8 +1576,7 @@ init_pragma (void)
{
if (flag_openacc)
{
- const int n_oacc_pragmas
- = sizeof (oacc_pragmas) / sizeof (*oacc_pragmas);
+ const int n_oacc_pragmas = ARRAY_SIZE (oacc_pragmas);
int i;
for (i = 0; i < n_oacc_pragmas; ++i)
@@ -1587,7 +1586,7 @@ init_pragma (void)
if (flag_openmp)
{
- const int n_omp_pragmas = sizeof (omp_pragmas) / sizeof (*omp_pragmas);
+ const int n_omp_pragmas = ARRAY_SIZE (omp_pragmas);
int i;
for (i = 0; i < n_omp_pragmas; ++i)
diff --git a/gcc/c-family/known-headers.cc b/gcc/c-family/known-headers.cc
index 8ad3eb3f466..01c86b27dc8 100644
--- a/gcc/c-family/known-headers.cc
+++ b/gcc/c-family/known-headers.cc
@@ -79,8 +79,7 @@ get_string_macro_hint (const char *name, enum stdlib lib)
if ((lib == STDLIB_C && flag_isoc99)
|| (lib == STDLIB_CPLUSPLUS && cxx_dialect >= cxx11 ))
{
- const size_t num_c99_cxx11_macros
- = sizeof (c99_cxx11_macros) / sizeof (c99_cxx11_macros[0]);
+ const size_t num_c99_cxx11_macros = ARRAY_SIZE (c99_cxx11_macros);
for (size_t i = 0; i < num_c99_cxx11_macros; i++)
if (strcmp (name, c99_cxx11_macros[i]) == 0)
return lib == STDLIB_C ? "<inttypes.h>" : "<cinttypes>";
@@ -204,7 +203,7 @@ get_stdlib_header_for_name (const char *name, enum stdlib lib)
{"WCHAR_MAX", {"<wchar.h>", "<cwchar>"} },
{"WCHAR_MIN", {"<wchar.h>", "<cwchar>"} }
};
- const size_t num_hints = sizeof (hints) / sizeof (hints[0]);
+ const size_t num_hints = ARRAY_SIZE (hints);
for (size_t i = 0; i < num_hints; i++)
if (strcmp (name, hints[i].name) == 0)
return hints[i].header[lib];