From 554fd8c5195424bdbcabf5de30fdc183aba391bd Mon Sep 17 00:00:00 2001 From: upstream source tree Date: Sun, 15 Mar 2015 20:14:05 -0400 Subject: obtained gcc-4.6.4.tar.bz2 from upstream website; verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository. --- gcc/testsuite/gcc.dg/c1x-typedef-1.c | 70 ++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/c1x-typedef-1.c (limited to 'gcc/testsuite/gcc.dg/c1x-typedef-1.c') diff --git a/gcc/testsuite/gcc.dg/c1x-typedef-1.c b/gcc/testsuite/gcc.dg/c1x-typedef-1.c new file mode 100644 index 000000000..a68b23ff5 --- /dev/null +++ b/gcc/testsuite/gcc.dg/c1x-typedef-1.c @@ -0,0 +1,70 @@ +/* Test typedef redeclaration in C1X. */ +/* { dg-do compile } */ +/* { dg-options "-std=c1x -pedantic-errors" } */ + +/* C1X permits typedefs to be redeclared to the same type, but not to + different-but-compatible types, and not when the type is variably + modified. */ + +#include + +typedef int TI; +typedef int TI2; +typedef TI2 TI; +typedef TI TI2; + +enum e { E1 = 0, E2 = INT_MAX, E3 = -1 }; +typedef enum e TE; +typedef enum e TE; /* { dg-message "previous declaration" } */ +typedef int TE; /* { dg-error "with different type" } */ + +struct s; +typedef struct s TS; +struct s { int i; }; +typedef struct s TS; + +typedef int IA[]; +typedef TI2 IA[]; /* { dg-message "previous declaration" } */ +typedef int A2[2]; +typedef TI A2[2]; /* { dg-message "previous declaration" } */ +typedef IA A2; /* { dg-error "with different type" } */ +typedef int A3[3]; +typedef A3 IA; /* { dg-error "with different type" } */ + +typedef void F(int); +typedef void F(TI); /* { dg-message "previous declaration" } */ +typedef void F(enum e); /* { dg-error "with different type" } */ + +typedef int G(void); +typedef TI G(void); /* { dg-message "previous declaration" } */ +typedef enum e G(void); /* { dg-error "with different type" } */ + +typedef int *P; +typedef TI *P; /* { dg-message "previous declaration" } */ +typedef enum e *P; /* { dg-error "with different type" } */ + +typedef void F2(); +typedef void F2(); /* { dg-message "previous declaration" } */ +typedef void F2(int); /* { dg-error "with different type" } */ + +void +f (void) +{ + int a = 1; + int b = 2; + typedef void FN(int (*p)[a]); + typedef void FN(int (*p)[b]); + typedef void FN(int (*p)[*]); /* { dg-message "previous declaration" } */ + typedef void FN(int (*p)[1]); /* { dg-error "with different type" } */ + typedef void FN2(int (*p)[a]); + typedef void FN2(int (*p)[b]); + typedef void FN2(int (*p)[*]); /* { dg-message "previous declaration" } */ + typedef void FN2(int (*p)[]); /* { dg-error "with different type" } */ + typedef int AV[a]; /* { dg-message "previous declaration" } */ + typedef int AV[b-1]; /* { dg-error "redefinition" } */ + typedef int AAa[a]; /* { dg-message "previous declaration" } */ + typedef int AAb[b-1]; + typedef AAa *VF(void); /* { dg-message "previous declaration" } */ + typedef AAb *VF(void); /* { dg-error "redefinition" } */ + typedef AAa AAa; /* { dg-error "redefinition" } */ +} -- cgit v1.2.3