diff options
Diffstat (limited to 'libgfortran/libgfortran.h')
-rw-r--r-- | libgfortran/libgfortran.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/libgfortran/libgfortran.h b/libgfortran/libgfortran.h index 285c36a..93e3591 100644 --- a/libgfortran/libgfortran.h +++ b/libgfortran/libgfortran.h @@ -39,6 +39,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see /* config.h MUST be first because it can affect system headers. */ #include "config.h" +#include <ctype.h> #include <stdio.h> #include <stdlib.h> #include <stddef.h> @@ -103,6 +104,20 @@ typedef off_t gfc_offset; #endif +/* These functions from <ctype.h> should only be used on values that can be + represented as unsigned char, otherwise the behavior is undefined. + Some targets have a char type that is signed, so we cast the argument + to unsigned char. See: + https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95177 + https://wiki.sei.cmu.edu/confluence/x/BNcxBQ + */ + +#define safe_isalnum(x) isalnum((unsigned char) (x)) +#define safe_isdigit(x) isdigit((unsigned char) (x)) +#define safe_tolower(x) tolower((unsigned char) (x)) +#define safe_toupper(x) toupper((unsigned char) (x)) + + /* The following macros can be used to annotate conditions which are likely or unlikely to be true. Avoid using them when a condition is only slightly more likely/less unlikely than average to avoid the performance penalties of |