From 4b72e8edacabbf47b7ec8035bbe87d4aaf5dca9a Mon Sep 17 00:00:00 2001 From: Richard Sandiford Date: Fri, 12 Apr 2002 10:59:33 +0000 Subject: [PATCH] * g++.dg/ext/attrib5.C, * g++.dg/lookup/struct1.C: New tests. From-SVN: r52215 --- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/ext/attrib5.C | 21 +++++++++++++++++++++ gcc/testsuite/g++.dg/lookup/struct1.C | 14 ++++++++++++++ 3 files changed, 40 insertions(+) create mode 100644 gcc/testsuite/g++.dg/ext/attrib5.C create mode 100644 gcc/testsuite/g++.dg/lookup/struct1.C diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index ccabe18f899..fdf1c38bd49 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2002-04-12 Richard Sandiford + + * g++.dg/ext/attrib5.C, + * g++.dg/lookup/struct1.C: New tests. + 2002-04-11 Jakub Jelinek * gcc.dg/20020411-1.c: New test. diff --git a/gcc/testsuite/g++.dg/ext/attrib5.C b/gcc/testsuite/g++.dg/ext/attrib5.C new file mode 100644 index 00000000000..f67510dabc7 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/attrib5.C @@ -0,0 +1,21 @@ +// There were two related problems here, depending on the vintage. At +// one time: +// +// typedef struct A { ... } A __attribute__ ((aligned (16))); +// +// would cause original_types to go into an infinite loop. At other +// times, the attributes applied to an explicit typedef would be lost +// (check_b3 would have a negative size). + +// First check that the declaration is accepted and has an effect. +typedef struct A { int i; } A __attribute__ ((aligned (16))); +int check_A[__alignof__ (A) >= 16 ? 1 : -1]; + +// Check that the alignment is only applied to the typedef. +struct B { int i; }; +struct B b1; +typedef struct B B __attribute__((aligned (16))); +struct B b2; +B b3; +int check_b1[__alignof__ (b1) == __alignof__ (b2) ? 1 : -1]; +int check_b3[__alignof__ (b3) >= 16 ? 1 : -1]; diff --git a/gcc/testsuite/g++.dg/lookup/struct1.C b/gcc/testsuite/g++.dg/lookup/struct1.C new file mode 100644 index 00000000000..c8bc0561be0 --- /dev/null +++ b/gcc/testsuite/g++.dg/lookup/struct1.C @@ -0,0 +1,14 @@ +// Various struct lookup tests. We didn't used to complain about +// the definition of C. + +struct A; +typedef struct A B; // { dg-error "previous declaration" } +struct B; // { dg-error "conflicting types" } + +typedef struct { int i; } C; // { dg-error "previous declaration" } +struct C; // { dg-error "conflicting types" } + +struct D; +typedef struct D D; +typedef struct D { int i; } D; +typedef struct D D; -- 2.30.2