summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/c1x-typedef-1.c
diff options
context:
space:
mode:
authorupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
committerupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
commit554fd8c5195424bdbcabf5de30fdc183aba391bd (patch)
tree976dc5ab7fddf506dadce60ae936f43f58787092 /gcc/testsuite/gcc.dg/c1x-typedef-1.c
downloadcbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.bz2
cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.xz
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
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.
Diffstat (limited to 'gcc/testsuite/gcc.dg/c1x-typedef-1.c')
-rw-r--r--gcc/testsuite/gcc.dg/c1x-typedef-1.c70
1 files changed, 70 insertions, 0 deletions
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 <limits.h>
+
+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" } */
+}