Commit 30235ede by Bernd Schmidt Committed by Bernd Schmidt

c99-const-expr-9.c (old_offsetof): Insert a cast to __UINTPTR_TYPE__.

	* gcc.dg/c99-const-expr-9.c (old_offsetof): Insert a cast to
	__UINTPTR_TYPE__.
	* gcc.c-torture/execute/pr15296.c (intptr_t): Likewise, with
	__INTPTR_TYPE__.
	* gcc.dg/pr14092-1.c (intptr_t): Likewise.
	* gcc.dg/tree-ssa/foldcast-1.c (ssize_t): Likewise.
	* gcc.dg/c90-const-expr-6.c (intptr_t): New typedef to replace ...
	(ptrdiff_t): ... this.  All uses changed.
	* gcc.dg/c99-const-expr-6.c (intptr_t, ptrdiff_t): Likewise.
	* gcc.dg/torture/pta-escape-1.c (foo): Change arg type to
	__INTPTR_TYPE__.
	(main): Cast argument to __INTPTR_TYPE__.
	* gcc.dg/20041106-1.c (main): Cast to __UINTPTR_TYPE__ rather than
	size_t.
	* gcc.dg/mallign.c (main): Likewise.
	* gcc.dg/pr38700.c (foo): Likewise.
	* gcc.dg/long-long-cst1.c (t): Likewise.
	* gcc.dg/c99-const-expr-10.c (p, q, f, h, h2): Likewise.
	* gcc.dg/array-10.c (c0, c1, c2, c3, c4, c5): Likewise.
	* gcc.dg/pointer-arith-10.c (foo): Likewise.
	* gcc.dg/pr25682.c (d, foo): Likewise.
	* gcc.dg/format/cast-1.c (f): Likewise.
	* gcc.dg/c90-const-expr-10.c
	* gcc.dg/pr41551.c (uintptr_t): New typedef, replacing...
	(size_t): ...this.  All uses changed.
	* gcc.c-torture/execute/pr22098-1.c (uintptr_t): Likewise.
	* gcc.c-torture/execute/pr22098-2.c (uintptr_t): Likewise.
	* gcc.c-torture/execute/pr22098-3.c (uintptr_t): Likewise.
	* gcc.dg/pr34856.c (uintptr_t): Likewise.
	* gcc.dg/sequence-pt-1.c: Likewise.
	* gcc.dg/c90-const-expr-9.c (uintptr_t): Likewise.
	* gcc.dg/max-1.c (intptr_t): Likewise, replacing ssize_t.
	* gcc.dg/pr39074.c (intptr_t): Define using __INTPTR_TYPE__.
	* gcc.dg/pr30744-1.c (my_intptr_t): New typedef.  Replace all uses
	of ptrdiff_t with it.
	* gcc.dg/inline-23.c (my_intptr_t): Likewise.
	* gcc.dg/pr37561.c (p): Use __INTPTR_TYPE__.
	* gcc.dg/vla-11.c (foo11b): Use __UINTPTR_TYPE__.

From-SVN: r186347
parent 6a091e8b
2012-04-11 Bernd Schmidt <bernds@codesourcery.com>
* gcc.dg/c99-const-expr-9.c (old_offsetof): Insert a cast to
__UINTPTR_TYPE__.
* gcc.c-torture/execute/pr15296.c (intptr_t): Likewise, with
__INTPTR_TYPE__.
* gcc.dg/pr14092-1.c (intptr_t): Likewise.
* gcc.dg/tree-ssa/foldcast-1.c (ssize_t): Likewise.
* gcc.dg/c90-const-expr-6.c (intptr_t): New typedef to replace ...
(ptrdiff_t): ... this. All uses changed.
* gcc.dg/c99-const-expr-6.c (intptr_t, ptrdiff_t): Likewise.
* gcc.dg/torture/pta-escape-1.c (foo): Change arg type to
__INTPTR_TYPE__.
(main): Cast argument to __INTPTR_TYPE__.
* gcc.dg/20041106-1.c (main): Cast to __UINTPTR_TYPE__ rather than
size_t.
* gcc.dg/mallign.c (main): Likewise.
* gcc.dg/pr38700.c (foo): Likewise.
* gcc.dg/long-long-cst1.c (t): Likewise.
* gcc.dg/c99-const-expr-10.c (p, q, f, h, h2): Likewise.
* gcc.dg/array-10.c (c0, c1, c2, c3, c4, c5): Likewise.
* gcc.dg/pointer-arith-10.c (foo): Likewise.
* gcc.dg/pr25682.c (d, foo): Likewise.
* gcc.dg/format/cast-1.c (f): Likewise.
* gcc.dg/c90-const-expr-10.c
* gcc.dg/pr41551.c (uintptr_t): New typedef, replacing...
(size_t): ...this. All uses changed.
* gcc.c-torture/execute/pr22098-1.c (uintptr_t): Likewise.
* gcc.c-torture/execute/pr22098-2.c (uintptr_t): Likewise.
* gcc.c-torture/execute/pr22098-3.c (uintptr_t): Likewise.
* gcc.dg/pr34856.c (uintptr_t): Likewise.
* gcc.dg/sequence-pt-1.c: Likewise.
* gcc.dg/c90-const-expr-9.c (uintptr_t): Likewise.
* gcc.dg/max-1.c (intptr_t): Likewise, replacing ssize_t.
* gcc.dg/pr39074.c (intptr_t): Define using __INTPTR_TYPE__.
* gcc.dg/pr30744-1.c (my_intptr_t): New typedef. Replace all uses
of ptrdiff_t with it.
* gcc.dg/inline-23.c (my_intptr_t): Likewise.
* gcc.dg/pr37561.c (p): Use __INTPTR_TYPE__.
* gcc.dg/vla-11.c (foo11b): Use __UINTPTR_TYPE__.
2012-04-11 Jason Merrill <jason@redhat.com>
PR debug/45088
......
......@@ -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
{
......
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);
......
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);
......
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);
......
......@@ -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));
......
......@@ -13,12 +13,12 @@ struct b3 { int x[a]; }; /* { dg-error "17:at file scope" } */
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 } */
......
......@@ -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" } */
......
......@@ -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" } */
......
......@@ -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
};
......
......@@ -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" } */
......
......@@ -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" } */
}
......@@ -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);
}
......@@ -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()
{
......
......@@ -9,7 +9,7 @@ typedef int word __attribute__((mode(word)));
int main()
{
if ((size_t)malloc (1) & (sizeof(word)-1))
if ((__UINTPTR_TYPE__)malloc (1) & (sizeof(word)-1))
abort ();
return 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 ();
......
/* { 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" } } */
......
......@@ -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;
......
......@@ -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);
......
......@@ -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;
}
}
......@@ -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)))
......
/* PR c++/37561 */
/* { dg-do compile } */
__extension__ __PTRDIFF_TYPE__ p;
__extension__ __INTPTR_TYPE__ p;
char q;
void
......
......@@ -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;
}
......@@ -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);
}
......@@ -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 *ptr, struct s *sptr,
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" } */
......
......@@ -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;
}
......
/* { 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;
......
......@@ -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 } */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment