rewrite fallthrough to HEIM_FALLTHROUGH to deal with new Apple SDKs

Apple clang version 14.0.0 (clang-1400.0.17.3.1) fails the build
because stds.h defines `fallthrough` as a macro which is then
expanded when base.h evaluates

  # if __has_attribute(fallthrough) && __clang_major__ >= 5

The macOS SDK defines `DISPATCH_FALLTHROUGH` as the macro instead
of `fallthrough`.

This change replaces the use of `fallthrough` in the tree with
`HEIM_FALLTHROUGH` and updates the declaration in configure logic
to define `HEIM_FALLTHROUGH` based upon existing definitions
(if any) of `fallthrough` or `DISPATCH_FALLTHROUGH`.
This commit is contained in:
Daria Phoebe Brashear
2022-09-16 09:57:24 -04:00
committed by Jeffrey Altman
parent f6d26bce66
commit 133f517482
21 changed files with 48 additions and 44 deletions

View File

@@ -100,10 +100,10 @@ rk_base32_encode(const void *data, int size, char **str, enum rk_base32_flags fl
p[6] = chars[(c & 0x0000000000000003e0ULL) >> 5];
p[7] = chars[(c & 0x00000000000000001fULL) >> 0];
switch (i - size) {
case 4: p[2] = p[3] = '='; fallthrough;
case 3: p[4] = '='; fallthrough;
case 2: p[5] = p[6] = '='; fallthrough;
case 1: p[7] = '='; fallthrough;
case 4: p[2] = p[3] = '='; HEIM_FALLTHROUGH;
case 3: p[4] = '='; HEIM_FALLTHROUGH;
case 2: p[5] = p[6] = '='; HEIM_FALLTHROUGH;
case 1: p[7] = '='; HEIM_FALLTHROUGH;
default: break;
}
p += 8;

View File

@@ -148,7 +148,7 @@ int teardown_test(void)
strcmp(dirname + len + 1 - sizeof(TESTDIR)/sizeof(char), TESTDIR) == 0) {
fallthrough;
HEIM_FALLTHROUGH;
} else {
/* did we create the directory? */
@@ -162,7 +162,7 @@ int teardown_test(void)
fprintf(stderr, "Can't change to test directory. Aborting cleanup.\n");
return -1;
} else {
fallthrough;
HEIM_FALLTHROUGH;
}
} else {
return -1;

View File

@@ -129,7 +129,7 @@ rk_fnmatch(const char *pattern, const char *string, int flags)
--pattern;
}
}
fallthrough;
HEIM_FALLTHROUGH;
default:
if (c != *string++)
return (FNM_NOMATCH);

View File

@@ -136,7 +136,7 @@ roken_get_homedir(char *home, size_t homesz)
}
return home;
}
fallthrough;
HEIM_FALLTHROUGH;
#else
#ifdef HAVE_GETPWNAM_R
size_t buflen = 2048;

View File

@@ -515,7 +515,7 @@ xyzprintf (struct snprintf_state *state, const char *char_format, va_list ap)
}
case '\0' :
--format;
fallthrough;
HEIM_FALLTHROUGH;
case '%' :
(*state->append_char)(state, c);
++len;

View File

@@ -377,7 +377,7 @@ strftime (char *buf, size_t maxsize, const char *format,
break;
case '\0' :
--format;
fallthrough;
HEIM_FALLTHROUGH;
case '%' :
ret = snprintf (buf, maxsize - n,
"%%");

View File

@@ -424,7 +424,7 @@ strptime (const char *buf, const char *format, struct tm *timeptr)
abort ();
case '\0' :
--format;
fallthrough;
HEIM_FALLTHROUGH;
case '%' :
if (*buf == '%')
++buf;