diff options
author | Joseph Myers <jsm28@cam.ac.uk> | 2000-10-15 21:30:17 +0100 |
---|---|---|
committer | Joseph Myers <jsm28@gcc.gnu.org> | 2000-10-15 21:30:17 +0100 |
commit | d79d42daae6e7492ea76c7057e2b71cc0e83df97 (patch) | |
tree | 4514fdc3fd33ea06e30d7cbc8ccb8b269e3c5554 /gcc | |
parent | 1fd2f510181091030051e8954a33775d59b8fca5 (diff) | |
download | gcc-d79d42daae6e7492ea76c7057e2b71cc0e83df97.zip gcc-d79d42daae6e7492ea76c7057e2b71cc0e83df97.tar.gz gcc-d79d42daae6e7492ea76c7057e2b71cc0e83df97.tar.bz2 |
c90-printf-2.c, [...]: Determine the type for intmax_t in the compiler using __typeof__ and the type...
* gcc.dg/c90-printf-2.c, gcc.dg/c90-scanf-2.c: Determine the type
for intmax_t in the compiler using __typeof__ and the type rules
for conditional expressions.
From-SVN: r36873
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/c90-printf-2.c | 25 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/c90-scanf-2.c | 25 |
3 files changed, 40 insertions, 16 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 0000b08..2e6782f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2000-10-15 Joseph S. Myers <jsm28@cam.ac.uk> + + * gcc.dg/c90-printf-2.c, gcc.dg/c90-scanf-2.c: Determine the type + for intmax_t in the compiler using __typeof__ and the type rules + for conditional expressions. + 2000-10-13 Jakub Jelinek <jakub@redhat.com> * gcc.dg/20001012-1.c: New test. diff --git a/gcc/testsuite/gcc.dg/c90-printf-2.c b/gcc/testsuite/gcc.dg/c90-printf-2.c index 4f2b9bf..1f8c544 100644 --- a/gcc/testsuite/gcc.dg/c90-printf-2.c +++ b/gcc/testsuite/gcc.dg/c90-printf-2.c @@ -13,14 +13,23 @@ __extension__ typedef long long int llong; /* This next definition is a kludge. When GCC has a <stdint.h> it should be used. */ -#include <limits.h> -#if INT_MAX == __LONG_LONG_MAX__ -typedef int intmax_t; -#elif LONG_MAX == __LONG_LONG_MAX__ -typedef long intmax_t; -#else -__extension__ typedef long long intmax_t; -#endif +/* (T *) if E is zero, (void *) otherwise. */ +#define type_if_not(T, E) __typeof__(0 ? (T *)0 : (void *)(E)) + +/* (T *) if E is nonzero, (void *) otherwise. */ +#define type_if(T, E) type_if_not(T, !(E)) + +/* Combine pointer types, all but one (void *). */ +#define type_comb2(T1, T2) __typeof__(0 ? (T1)0 : (T2)0) +#define type_comb3(T1, T2, T3) type_comb2(T1, type_comb2(T2, T3)) + +#define maybe_int_ptr type_if(int, sizeof(int) == sizeof(llong)) +#define maybe_long_ptr type_if(long, sizeof(long) == sizeof(llong) && sizeof(long) > sizeof(int)) +#define maybe_long_long_ptr type_if(llong, sizeof(llong) > sizeof(long)) + +#define intmax_type_ptr type_comb3(maybe_int_ptr, maybe_long_ptr, maybe_long_long_ptr) + +typedef __typeof__(*((intmax_type_ptr)0)) intmax_t; extern int printf (const char *, ...); diff --git a/gcc/testsuite/gcc.dg/c90-scanf-2.c b/gcc/testsuite/gcc.dg/c90-scanf-2.c index a7d2ab3..786acdd 100644 --- a/gcc/testsuite/gcc.dg/c90-scanf-2.c +++ b/gcc/testsuite/gcc.dg/c90-scanf-2.c @@ -13,14 +13,23 @@ __extension__ typedef long long int llong; /* This next definition is a kludge. When GCC has a <stdint.h> it should be used. */ -#include <limits.h> -#if INT_MAX == __LONG_LONG_MAX__ -typedef int intmax_t; -#elif LONG_MAX == __LONG_LONG_MAX__ -typedef long intmax_t; -#else -__extension__ typedef long long intmax_t; -#endif +/* (T *) if E is zero, (void *) otherwise. */ +#define type_if_not(T, E) __typeof__(0 ? (T *)0 : (void *)(E)) + +/* (T *) if E is nonzero, (void *) otherwise. */ +#define type_if(T, E) type_if_not(T, !(E)) + +/* Combine pointer types, all but one (void *). */ +#define type_comb2(T1, T2) __typeof__(0 ? (T1)0 : (T2)0) +#define type_comb3(T1, T2, T3) type_comb2(T1, type_comb2(T2, T3)) + +#define maybe_int_ptr type_if(int, sizeof(int) == sizeof(llong)) +#define maybe_long_ptr type_if(long, sizeof(long) == sizeof(llong) && sizeof(long) > sizeof(int)) +#define maybe_long_long_ptr type_if(llong, sizeof(llong) > sizeof(long)) + +#define intmax_type_ptr type_comb3(maybe_int_ptr, maybe_long_ptr, maybe_long_long_ptr) + +typedef __typeof__(*((intmax_type_ptr)0)) intmax_t; extern int scanf (const char *, ...); |