diff options
author | jsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-09-24 17:22:20 +0000 |
---|---|---|
committer | jsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-09-24 17:22:20 +0000 |
commit | 5dad28f1aa5236c87acd9baa5fed055743addf04 (patch) | |
tree | 0df83d2241d0c2e8cf4abfc9975db885362bef6d /gcc/testsuite/gcc.dg | |
parent | e9437a8f0034393543bef9634d5488654c03d310 (diff) | |
download | gcc-5dad28f1aa5236c87acd9baa5fed055743addf04.tar.gz |
PR c/17188
* c-decl.c (diagnose_mismatched_decls): Check for duplicate
declarations of enumerators.
(start_struct): Check TYPE_SIZE rather than TYPE_FIELDS to check
for redefinition. Check for nested redefinition.
(finish_struct): Don't check for nested redefinition.
(start_enum): Check for nested redefinition.
testsuite:
* gcc.dg/nested-redef-1.c, gcc.dg/pr17188-1.c: New tests.
* gcc.dg/decl-3.c: Adjust expected message.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@88063 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite/gcc.dg')
-rw-r--r-- | gcc/testsuite/gcc.dg/decl-3.c | 2 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/nested-redef-1.c | 44 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/pr17188-1.c | 31 |
3 files changed, 76 insertions, 1 deletions
diff --git a/gcc/testsuite/gcc.dg/decl-3.c b/gcc/testsuite/gcc.dg/decl-3.c index 2bfac89c136..5bbe19cd224 100644 --- a/gcc/testsuite/gcc.dg/decl-3.c +++ b/gcc/testsuite/gcc.dg/decl-3.c @@ -2,4 +2,4 @@ /* { dg-do compile } */ enum { CODES }; /* { dg-error "previous definition" } */ -enum { CODES }; /* { dg-error "conflicting types" } */ +enum { CODES }; /* { dg-error "conflicting types|redeclaration of enumerator" } */ diff --git a/gcc/testsuite/gcc.dg/nested-redef-1.c b/gcc/testsuite/gcc.dg/nested-redef-1.c new file mode 100644 index 00000000000..34b92d8f571 --- /dev/null +++ b/gcc/testsuite/gcc.dg/nested-redef-1.c @@ -0,0 +1,44 @@ +/* Test diagnosis of nested tag redefinitions. */ +/* Origin: Joseph Myers <jsm@polyomino.org.uk> */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +struct s0 { + struct s0 { int a; } x; /* { dg-error "error: nested redefinition of 'struct s0'" } */ +}; + +struct s1 { + const struct s1 { int b; } x; /* { dg-error "error: nested redefinition of 'struct s1'" } */ +}; + +struct s2 { + struct s2 { int c; } *x; /* { dg-error "error: nested redefinition of 'struct s2'" } */ +}; + +struct s3 { + struct s4 { + struct s5 { + struct s3 { int a; } **x; /* { dg-error "error: nested redefinition of 'struct s3'" } */ + } y; + } z; +}; + +struct s6; +struct s6 { struct s6 *p; }; + +union u0 { + union u0 { int c; } *x; /* { dg-error "error: nested redefinition of 'union u0'" } */ +}; + +enum e0 { + E0 = sizeof(enum e0 { E1 }) /* { dg-error "error: nested redefinition of 'enum e0'" } */ +}; + +enum e1 { + E2 = sizeof(enum e2 { E2 }), /* { dg-error "error: redeclaration of enumerator 'E2'" } */ + /* { dg-error "previous definition" "previous E2" { target *-*-* } 38 } */ + E3 +}; + +enum e3; +enum e3 { E4 = 0 }; diff --git a/gcc/testsuite/gcc.dg/pr17188-1.c b/gcc/testsuite/gcc.dg/pr17188-1.c new file mode 100644 index 00000000000..634e60c0363 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr17188-1.c @@ -0,0 +1,31 @@ +/* A redefinition of an empty struct should be diagnosed the same as a + redefinition of any other tag, but formerly only s2 and s4 were + diagnosed. Bug 17188. */ +/* Origin: Joseph Myers <jsm@polyomino.org.uk> */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +struct s0 { }; +struct s0; +struct s0 { }; /* { dg-error "error: redefinition of 'struct s0'" } */ + +struct s1 { }; +struct s1 { }; /* { dg-error "error: redefinition of 'struct s1'" } */ + +struct s2 { int a : 1; }; +struct s2 { int a : 1; }; /* { dg-error "error: redefinition of 'struct s2'" } */ + +struct s3 { }; +struct s3 { int a : 1; }; /* { dg-error "error: redefinition of 'struct s3'" } */ + +struct s4 { int a : 1; }; +struct s4 { }; /* { dg-error "error: redefinition of 'struct s4'" } */ + +struct s5 { int a : 1; }; +struct s5; + +struct s6; +struct s6 { int a : 1; }; + +struct s7; +struct s7 { }; |