===================================================================
@@ -1,13 +1,13 @@
extern void abort (void);
extern void exit (int);
-typedef __SIZE_TYPE__ size_t;
+typedef __UINTPTR_TYPE__ uintptr_t;
int
main (void)
{
int a = 0;
int *p;
- size_t b;
- b = (size_t)(p = &(int []){0, 1, 2}[++a]);
+ uintptr_t b;
+ b = (uintptr_t)(p = &(int []){0, 1, 2}[++a]);
if (a != 1 || *p != 1 || *(int *)b != 1)
abort ();
exit (0);
===================================================================
@@ -1,6 +1,6 @@
extern void abort (void);
extern void exit (int);
-typedef __SIZE_TYPE__ size_t;
+typedef __UINTPTR_TYPE__ uintptr_t;
int n = 0;
int f (void) { return ++n; }
int
@@ -8,8 +8,8 @@ main (void)
{
int a = 0;
int *p;
- size_t b;
- b = (size_t)(p = &(int []){0, f(), 2}[1]);
+ uintptr_t b;
+ b = (uintptr_t)(p = &(int []){0, f(), 2}[1]);
if (*p != 1 || *(int *)b != 1 || n != 1)
abort ();
exit (0);
===================================================================
@@ -3,7 +3,7 @@
fall-through code, while that register held a pointer used in code at
the branch target. */
-typedef int __attribute__ ((mode (__pointer__))) intptr_t;
+typedef __INTPTR_TYPE__ intptr_t;
typedef intptr_t W;
union u0
{
===================================================================
@@ -1,13 +1,13 @@
extern void abort (void);
extern void exit (int);
-typedef __SIZE_TYPE__ size_t;
+typedef __UINTPTR_TYPE__ uintptr_t;
int
main (void)
{
int a = 0;
int *p;
- size_t b;
- b = (size_t)(p = &(int []){0, 1, 2}[1]);
+ uintptr_t b;
+ b = (uintptr_t)(p = &(int []){0, 1, 2}[1]);
if (*p != 1 || *(int *)b != 1)
abort ();
exit (0);
===================================================================
@@ -3,7 +3,7 @@
/* { dg-options "-O2 -msse2" { target { i?86-*-* x86_64-*-* } } } */
/* { dg-options "-O2 -maltivec" { target { powerpc*-*-linux* && powerpc_altivec_ok } } } */
-typedef unsigned __attribute__ ((__mode__ (__pointer__))) uintptr_t;
+typedef __UINTPTR_TYPE__ uintptr_t;
#undef __vector
#define __vector __attribute__ ((__vector_size__ (16)))
===================================================================
@@ -14,7 +14,7 @@ struct t {
int b[2];
};
-#define old_offsetof(TYPE, MEMBER) ((__SIZE_TYPE__) &((TYPE *)0)->MEMBER)
+#define old_offsetof(TYPE, MEMBER) ((__SIZE_TYPE__)(__UINTPTR_TYPE__) &((TYPE *)0)->MEMBER)
enum e {
E1 = old_offsetof (struct s, a), /* { dg-error "constant" } */
===================================================================
@@ -21,7 +21,7 @@ int main ()
struct S *s;
ptr = malloc (3*ps);
- page = (char *)(((size_t)ptr + (ps - 1)) & -ps);
+ page = (char *)(((__UINTPTR_TYPE__)ptr + (ps - 1)) & -ps);
munmap (page + ps, ps);
s = (struct S *)(page + ps - sizeof(struct S));
===================================================================
@@ -5,7 +5,7 @@
int
foo ()
{
- __SIZE_TYPE__ s = __builtin_expect ((__SIZE_TYPE__)&&L, 0);
+ __UINTPTR_TYPE__ s = __builtin_expect ((__UINTPTR_TYPE__)&&L, 0);
L:
return 0;
}
===================================================================
@@ -8,7 +8,7 @@
int n = 0, p[n * 0 + 1]; /* { dg-error "variabl" } */
/* PR 31871. */
-extern int c[1 + ((__PTRDIFF_TYPE__) (void *) 0)]; /* { dg-error "variab" } */
+extern int c[1 + ((__INTPTR_TYPE__) (void *) 0)]; /* { dg-error "variab" } */
/* Implicit conversions from floating-point constants are not OK,
although explicit ones are. */
@@ -32,7 +32,7 @@ struct s {
};
enum e {
- E = (1 + ((__PTRDIFF_TYPE__) (void *) 0)), /* { dg-error "constant" } */
+ E = (1 + ((__INTPTR_TYPE__) (void *) 0)), /* { dg-error "constant" } */
E2 = 0
};
===================================================================
@@ -7,19 +7,16 @@
/* m32c has varying sized pointers */
/* { dg-skip-if "" { "m32c-*-*" } { "*" } { "-mcpu=m32c" "-mcpu=m32cm" } } */
-/* Kludge to make it signed. */
-#define unsigned signed
-__extension__ typedef __SIZE_TYPE__ ssize_t;
-#undef unsigned
+__extension__ typedef __INTPTR_TYPE__ intptr_t;
extern void abort (void);
-ssize_t fff[10];
+intptr_t fff[10];
-void f(ssize_t a, ssize_t b)
+void f(intptr_t a, intptr_t b)
{
- ssize_t crcc = b;
- ssize_t d = *((ssize_t*)(a+1));
+ intptr_t crcc = b;
+ intptr_t d = *((intptr_t*)(a+1));
int i;
a = d >= b? d:b;
@@ -32,11 +29,11 @@ void f(ssize_t a, ssize_t b)
/* The variable a cannot be a local variable as we get better aliasing
now and decide that the store to a is dead. The better aliasing comes
from better representation of pointer arithmetic. */
-ssize_t a = 10;
+intptr_t a = 10;
int main(void)
{
int i;
- f((ssize_t)(&a)-1,0);
+ f((intptr_t)(&a)-1,0);
for(i = 0;i<10;i++)
if (fff[i]!=10)
abort ();
===================================================================
@@ -3,10 +3,10 @@
/* Make sure we do not ICE. */
-__extension__ typedef __SIZE_TYPE__ size_t;
+__extension__ typedef __UINTPTR_TYPE__ uintptr_t;
int main(void)
{
int var, *p = &var;
- return (double)(size_t)(p);
+ return (double)(uintptr_t)(p);
}
===================================================================
@@ -7,7 +7,7 @@ extern void abort();
struct st{
int _mark;
};
-unsigned long long t = ((int)(__SIZE_TYPE__)&(((struct st*)16)->_mark) - 32);
+unsigned long long t = ((int)(__UINTPTR_TYPE__)&(((struct st*)16)->_mark) - 32);
int main()
{
===================================================================
@@ -13,12 +13,12 @@ struct b3 { int x[a]; }; /* { dg-error "
struct b4 { int (*x)[a]; }; /* { dg-error "19:at file scope" } */
typeof (int [a]) b5; /* { dg-error "at file scope|outside of any function" } */
-int c0[(__SIZE_TYPE__)&a]; /* { dg-error "5:at file scope" } */
-int (*c1)[(__SIZE_TYPE__)&a]; /* { dg-error "7:at file scope" } */
-int (*c2())[(__SIZE_TYPE__)&a]; /* { dg-error "7:at file scope" } */
-struct c3 { int x[(__SIZE_TYPE__)&a]; }; /* { dg-error "17:at file scope" } */
-struct c4 { int (*x)[(__SIZE_TYPE__)&a]; }; /* { dg-error "19:at file scope" } */
-typeof (int [(__SIZE_TYPE__)&a]) c5; /* { dg-error "34:at file scope" } */
+int c0[(__UINTPTR_TYPE__)&a]; /* { dg-error "5:at file scope" } */
+int (*c1)[(__UINTPTR_TYPE__)&a]; /* { dg-error "7:at file scope" } */
+int (*c2())[(__UINTPTR_TYPE__)&a]; /* { dg-error "7:at file scope" } */
+struct c3 { int x[(__UINTPTR_TYPE__)&a]; }; /* { dg-error "17:at file scope" } */
+struct c4 { int (*x)[(__UINTPTR_TYPE__)&a]; }; /* { dg-error "19:at file scope" } */
+typeof (int [(__UINTPTR_TYPE__)&a]) c5; /* { dg-error "37:at file scope" } */
int d0[1/0]; /* { dg-error "5:at file scope" } */
/* { dg-warning "9:division by zero" "" { target *-*-* } 23 } */
===================================================================
@@ -1,9 +1,9 @@
/* { dg-do compile } */
/* { dg-options "-fdump-tree-original" } */
-char *foo(char *p, __SIZE_TYPE__ i)
+char *foo(char *p, __UINTPTR_TYPE__ i)
{
- return (char *)i + (__SIZE_TYPE__)p;
+ return (char *)i + (__UINTPTR_TYPE__)p;
}
/* { dg-final { scan-tree-dump "p +" "original" } } */
===================================================================
@@ -2,15 +2,17 @@
/* { dg-options "-O2" } */
#include <stddef.h>
+typedef __INTPTR_TYPE__ my_intptr_t;
+
typedef struct {
- ptrdiff_t unique;
+ my_intptr_t unique;
} G;
void r(G* n)
{
- ptrdiff_t p;
- if (((G *) ((void *)((~(ptrdiff_t)(p))))) != ((void *)0)) {
- ((G *) ((void *)((~(ptrdiff_t)(p)))))->unique = n->unique;
+ my_intptr_t p;
+ if (((G *) ((void *)((~(my_intptr_t)(p))))) != ((void *)0)) {
+ ((G *) ((void *)((~(my_intptr_t)(p)))))->unique = n->unique;
}
}
===================================================================
@@ -1,7 +1,7 @@
/* PR c++/37561 */
/* { dg-do compile } */
-__extension__ __PTRDIFF_TYPE__ p;
+__extension__ __INTPTR_TYPE__ p;
char q;
void
===================================================================
@@ -6,7 +6,7 @@
/* Define this so that we are more portable. The testcase in the
PR failed on 64-bit hosts. */
-typedef int __attribute__ ((mode (__pointer__))) intptr_t;
+typedef __INTPTR_TYPE__ intptr_t;
typedef struct _PLCI {
unsigned char x;
===================================================================
@@ -7,7 +7,7 @@
/* { dg-options "-std=c99 -pedantic-errors" } */
void foo11a(int x[sizeof(int *(*)[*])]); /* { dg-warning "not in a declaration" } */
-void foo11b(__SIZE_TYPE__ x, int y[(__SIZE_TYPE__)(int (*)[*])x]); /* { dg-warning "not in a declaration" } */
+void foo11b(__SIZE_TYPE__ x, int y[(__UINTPTR_TYPE__)(int (*)[*])x]); /* { dg-warning "not in a declaration" } */
void foo11c(struct s { int (*x)[*]; } *y); /* { dg-error "a member of a structure or union cannot have a variably modified type" "variably modified" } */
/* { dg-warning "'struct s' declared inside parameter list" "struct decl" { target *-*-* } 11 } */
/* { dg-warning "its scope is only this definition or declaration" "struct scope" { target *-*-* } 11 } */
===================================================================
@@ -15,7 +15,7 @@ extern int fnb (int, int);
extern int fnc (int *);
extern int sprintf (char *, const char *, ...);
-typedef __SIZE_TYPE__ size_t;
+typedef __UINTPTR_TYPE__ uintptr_t;
void
foo (int a, int b, int n, int p, int *ptr, struct s *sptr,
@@ -32,9 +32,9 @@ foo (int a, int b, int n, int p, int *pt
ap[++n] = bp[--n]; /* { dg-warning "undefined" "sequence point warning" } */
cp[n][n] = cp[n][n]++; /* { dg-warning "undefined" "sequence point warning" } */
cp[n][p] = cp[n][n++]; /* { dg-warning "undefined" "sequence point warning" } */
- *ptr++ = (size_t)ptr++; /* { dg-warning "undefined" "sequence point warning" } */
+ *ptr++ = (uintptr_t)ptr++; /* { dg-warning "undefined" "sequence point warning" } */
sptr->a = sptr->a++; /* { dg-warning "undefined" "sequence point warning" } */
- sptr->a = (size_t)(sptr++); /* { dg-warning "undefined" "sequence point warning" } */
+ sptr->a = (uintptr_t)(sptr++); /* { dg-warning "undefined" "sequence point warning" } */
*ptr++ = fn (*ptr); /* { dg-warning "undefined" "sequence point warning" } */
a = b = a++; /* { dg-warning "undefined" "sequence point warning" } */
b = a = --b; /* { dg-warning "undefined" "sequence point warning" } */
===================================================================
@@ -15,8 +15,9 @@ struct t {
};
__extension__ typedef __SIZE_TYPE__ size_t;
+__extension__ typedef __UINTPTR_TYPE__ uintptr_t;
-#define old_offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
+#define old_offsetof(TYPE, MEMBER) ((size_t) (uintptr_t) &((TYPE *)0)->MEMBER)
enum e {
E1 = old_offsetof (struct s, a), /* { dg-error "constant" } */
===================================================================
@@ -2,7 +2,7 @@
/* { dg-options "-fdump-tree-alias" } */
/* { dg-skip-if "" { *-*-* } { "-O0" "-fno-fat-lto-objects" } { "" } } */
-typedef __PTRDIFF_TYPE__ intptr_t;
+typedef __INTPTR_TYPE__ intptr_t;
int i;
void __attribute__((noinline))
===================================================================
@@ -9,7 +9,7 @@ bar (void)
*p = 1;
}
int __attribute__((noinline,noclone))
-foo (__SIZE_TYPE__ addr)
+foo (__INTPTR_TYPE__ addr)
{
int i;
/* q points to ANYTHING */
@@ -25,7 +25,7 @@ extern void abort (void);
int
main()
{
- if (foo ((__SIZE_TYPE__)&p) != 1)
+ if (foo ((__INTPTR_TYPE__)&p) != 1)
abort ();
return 0;
}
===================================================================
@@ -1,7 +1,7 @@
/* { dg-do compile } */
/* { dg-options "-fdump-tree-original" } */
-typedef int ssize_t __attribute__((mode(pointer)));
+typedef __INTPTR_TYPE__ ssize_t;
ssize_t foo (ssize_t x)
{
return (ssize_t)(char *)x;
===================================================================
@@ -3,16 +3,19 @@
/* Make sure we can inline a varargs function whose variable arguments
are not used. See PR32493. */
#include <stddef.h>
+
+typedef __INTPTR_TYPE__ my_intptr_t;
+
static inline __attribute__((always_inline)) void __check_printsym_format(const
char *fmt, ...)
{
}
static inline __attribute__((always_inline)) void print_symbol(const char *fmt,
-ptrdiff_t addr)
+my_intptr_t addr)
{
__check_printsym_format(fmt, "");
}
void do_initcalls(void **call)
{
- print_symbol(": %s()", (ptrdiff_t) *call);
+ print_symbol(": %s()", (my_intptr_t) *call);
}
===================================================================
@@ -9,7 +9,7 @@ typedef int word __attribute__((mode(wor
int main()
{
- if ((size_t)malloc (1) & (sizeof(word)-1))
+ if ((__UINTPTR_TYPE__)malloc (1) & (sizeof(word)-1))
abort ();
return 0;
}
===================================================================
@@ -4,13 +4,13 @@
/* { dg-do compile } */
/* { dg-options "-std=iso9899:1990 -pedantic-errors" } */
-__extension__ typedef __PTRDIFF_TYPE__ ptrdiff_t;
+__extension__ typedef __INTPTR_TYPE__ intptr_t;
/* PR 29116. */
int n = 0, p[n * 0 + 1]; /* { dg-error "variabl|can't be evaluated" } */
/* PR 31871. */
-extern int c[1 + ((ptrdiff_t) (void *) 0)]; /* { dg-error "variab|can't be evaluated" } */
+extern int c[1 + ((intptr_t) (void *) 0)]; /* { dg-error "variab|can't be evaluated" } */
/* Implicit conversions from floating-point constants are not OK,
although explicit ones are. */
@@ -34,7 +34,7 @@ struct s {
};
enum e {
- E = (1 + ((ptrdiff_t) (void *) 0)), /* { dg-error "constant" } */
+ E = (1 + ((intptr_t) (void *) 0)), /* { dg-error "constant" } */
E2 = 0
};
@@ -46,7 +46,7 @@ enum f {
void
f (int a)
{
- int v[1 + ((ptrdiff_t) (void *) 0)]; /* { dg-error "variab|can't be evaluated" } */
+ int v[1 + ((intptr_t) (void *) 0)]; /* { dg-error "variab|can't be evaluated" } */
switch (a)
{
case (n * 0 + 1): /* { dg-error "constant" } */
===================================================================
@@ -11,7 +11,7 @@ struct S
};
char c[(char *) &((struct S *) 0)->b - (char *) 0]; /* { dg-warning "variably modified" } */
-char d[(__SIZE_TYPE__) &((struct S *) 8)->b]; /* { dg-warning "variably modified" } */
+char d[(__UINTPTR_TYPE__) &((struct S *) 8)->b]; /* { dg-warning "variably modified" } */
char e[sizeof (c) == __builtin_offsetof (struct S, b) ? 1 : -1];
char f[sizeof (d) == __builtin_offsetof (struct S, b) + 8 ? 1 : -1];
@@ -21,7 +21,7 @@ void
foo (void)
{
char g[(char *) &((struct S *) 0)->b - (char *) 0];
- char h[(__SIZE_TYPE__) &((struct S *) 8)->b];
+ char h[(__UINTPTR_TYPE__) &((struct S *) 8)->b];
char i[sizeof (g) == __builtin_offsetof (struct S, b) ? 1 : -1];
char j[sizeof (h) == __builtin_offsetof (struct S, b) + 8 ? 1 : -1];
bar (g, h);
===================================================================
@@ -11,6 +11,6 @@ void
f (int x)
{
printf("%s", x); /* { dg-warning "format" } */
- printf((char *)(size_t)"%s", x); /* { dg-warning "format" } */
+ printf((char *)(__UINTPTR_TYPE__)"%s", x); /* { dg-warning "format" } */
printf((char *)(char)"%s", x); /* { dg-warning "cast from pointer to integer of different size" } */
}