diff options
author | Ian Lance Taylor <iant@google.com> | 2010-10-04 03:50:39 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2010-10-04 03:50:39 +0000 |
commit | 478a1c5b906a165853b77a8dd1c0548b66ace018 (patch) | |
tree | c18cd90272c7a2cb06261eb2a6d5a845ebb150f2 /gcc/testsuite/gcc.dg/anon-struct-13.c | |
parent | 3b5269a95e9e50001c2e4fabbb1712c9e984a09d (diff) | |
download | gcc-478a1c5b906a165853b77a8dd1c0548b66ace018.zip gcc-478a1c5b906a165853b77a8dd1c0548b66ace018.tar.gz gcc-478a1c5b906a165853b77a8dd1c0548b66ace018.tar.bz2 |
c-typeck.c (lookup_field): If -fplan9-extensions, permit referring to a field using a typedef name.
gcc/:
* c-typeck.c (lookup_field): If -fplan9-extensions, permit
referring to a field using a typedef name.
(find_anonymous_field_with_type): New static function.
(convert_to_anonymous_field): New static function.
(convert_for_assignment): If -fplan9-extensions, permit converting
pointer to struct to pointer to anonymous field.
* c-decl.c (grokfield): If -fplan9-extensions, permit anonymous
fields.
(is_duplicate_field): New static function.
(detect_field_duplicates_hash): If -fplan9-extensions, check for
typedef names duplicating field names.
(detect_field_duplicates): Likewise.
* doc/invoke.texi (Option Summary): Mention -fplan9-extensions.
(C Dialect Options): Document -fplan9-extensions.
* doc/extend.texi (Unnamed Fields): Document -fplan9-extensions.
gcc/c-family/:
* c.opt (-fplan9-extensions): New option.
gcc/testsuite/:
* gcc.dg/anon-struct-11.c: New test.
* gcc.dg/anon-struct-12.c: New test.
* gcc.dg/anon-struct-13.c: New test.
* gcc.dg/anon-struct-14.c: New test.
From-SVN: r164926
Diffstat (limited to 'gcc/testsuite/gcc.dg/anon-struct-13.c')
-rw-r--r-- | gcc/testsuite/gcc.dg/anon-struct-13.c | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/anon-struct-13.c b/gcc/testsuite/gcc.dg/anon-struct-13.c new file mode 100644 index 0000000..6a50814 --- /dev/null +++ b/gcc/testsuite/gcc.dg/anon-struct-13.c @@ -0,0 +1,76 @@ +/* { dg-do compile } */ +/* { dg-options "-fplan9-extensions" } */ + +/* Test for ambiguity when using the Plan 9 extensions. */ + +struct A { + char a; /* { dg-error "duplicate member" } */ +}; + +struct B +{ + struct A; + struct A; +}; + +char +f1 (struct B *p) +{ + return p->a; /* { dg-error "no member" } */ +} + +void +f2 (struct A *p) /* { dg-message "expected" } */ +{ +} + +void +f3 (struct B *p) +{ + f2 (p); /* { dg-warning "incompatible pointer type" } */ +} + +struct C +{ + char c; /* { dg-error "duplicate member" } */ +}; + +struct D +{ + struct C; +}; + +struct E +{ + struct C; + struct D; +}; + +char +f4 (struct E *p) +{ + return p->c; /* { dg-error "no member" } */ +} + +void +f6 (struct C *p) /* { dg-message "expected" } */ +{ +} + +void +f7 (struct E *p) +{ + f6 (p); /* { dg-warning "incompatible pointer type" } */ +} + +struct A +f8 (struct B *p) +{ + return p->A; /* { dg-error "no member" } */ +} + +struct C +f9 (struct E *p) +{ + return p->C; /* { dg-error "no member" } */ +} |