2009-12-14 20:36:25 +03:00
|
|
|
// RUN: clang -cc1 -fsyntax-only -verify %s
|
2007-10-04 04:22:33 +04:00
|
|
|
|
2009-01-19 22:26:10 +03:00
|
|
|
struct S; // expected-note{{forward declaration of 'struct S'}}
|
2007-09-14 20:27:55 +04:00
|
|
|
typedef int FOO();
|
|
|
|
|
|
|
|
@interface INTF
|
|
|
|
{
|
|
|
|
struct F {} JJ;
|
2009-01-19 22:26:10 +03:00
|
|
|
int arr[]; // expected-error {{field has incomplete type}}
|
|
|
|
struct S IC; // expected-error {{field has incomplete type}}
|
2008-11-24 02:12:31 +03:00
|
|
|
struct T { // expected-note {{previous definition is here}}
|
2009-12-07 03:22:08 +03:00
|
|
|
struct T {} X; // expected-error {{nested redefinition of 'T'}} \
|
|
|
|
// expected-error {{field has incomplete type}}
|
2007-10-04 04:22:33 +04:00
|
|
|
}YYY;
|
2007-09-14 20:27:55 +04:00
|
|
|
FOO BADFUNC; // expected-error {{field 'BADFUNC' declared as a function}}
|
Unify the code for defining tags in C and C++, so that we always
introduce a Scope for the body of a tag. This reduces the number of
semantic differences between C and C++ structs and unions, and will
help with other features (e.g., anonymous unions) in C. Some important
points:
- Fields are now in the "member" namespace (IDNS_Member), to keep
them separate from tags and ordinary names in C. See the new test
in Sema/member-reference.c for an example of why this matters. In
C++, ordinary and member name lookup will find members in both the
ordinary and member namespace, so the difference between
IDNS_Member and IDNS_Ordinary is erased by Sema::LookupDecl (but
only in C++!).
- We always introduce a Scope and push a DeclContext when we're
defining a tag, in both C and C++. Previously, we had different
actions and different Scope/CurContext behavior for enums, C
structs/unions, and C++ structs/unions/classes. Now, it's one pair
of actions. (Yay!)
There's still some fuzziness in the handling of struct/union/enum
definitions within other struct/union/enum definitions in C. We'll
need to do some more cleanup to eliminate some reliance on CurContext
before we can solve this issue for real. What we want is for something
like this:
struct X {
struct T { int x; } t;
};
to introduce T into translation unit scope (placing it at the
appropriate point in the IdentifierResolver chain, too), but it should
still have struct X as its lexical declaration
context. PushOnScopeChains isn't smart enough to do that yet, though,
so there's a FIXME test in nested-redef.c
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61940 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-08 23:45:30 +03:00
|
|
|
int kaka; // expected-note {{previous declaration is here}}
|
2007-09-14 20:27:55 +04:00
|
|
|
int kaka; // expected-error {{duplicate member 'kaka'}}
|
2009-01-19 22:26:10 +03:00
|
|
|
char ch[]; // expected-error {{field has incomplete type}}
|
2007-09-14 20:27:55 +04:00
|
|
|
}
|
|
|
|
@end
|