blob: 70478e0f32c4718e7fce1f9b46a2939ad4834bee [file] [log] [blame]
Daniel Dunbard7d5f022009-03-24 02:24:46 +00001// RUN: clang-cc -fsyntax-only -verify %s
Douglas Gregor3218c4b2009-01-09 22:42:13 +00002
3// Test the use of elaborated-type-specifiers to inject the names of
4// structs (or classes or unions) into an outer scope as described in
5// C++ [basic.scope.pdecl]p5.
6typedef struct S1 {
7 union {
8 struct S2 *x;
9 struct S3 *y;
10 };
11} S1;
12
13bool test_elab(S1 *s1, struct S2 *s2, struct S3 *s3) {
14 if (s1->x == s2) return true;
15 if (s1->y == s3) return true;
16 return false;
17}
18
19namespace NS {
20 class X {
21 public:
22 void test_elab2(struct S4 *s4);
23 };
24
25 void X::test_elab2(S4 *s4) { }
26}
27
28void test_X_elab(NS::X x) {
29 struct S4 *s4 = 0;
Douglas Gregor24c46b32009-03-19 04:25:59 +000030 x.test_elab2(s4); // expected-error{{incompatible type passing 'struct S4 *', expected 'struct NS::S4 *'}}
Douglas Gregor3218c4b2009-01-09 22:42:13 +000031}
32
33namespace NS {
34 S4 *get_S4();
35}
36
37void test_S5_scope() {
38 S4 *s4; // expected-error{{use of undeclared identifier 'S4'}}
39}
40
Douglas Gregor3218c4b2009-01-09 22:42:13 +000041int test_funcparam_scope(struct S5 * s5) {
42 struct S5 { int y; } *s5_2 = 0;
Douglas Gregor0c6db942009-05-04 06:07:12 +000043 if (s5 == s5_2) return 1; // expected-error {{comparison of distinct pointer types ('struct S5 *' and 'struct S5 *')}}
Douglas Gregor3218c4b2009-01-09 22:42:13 +000044 return 0;
45}
46
47