summaryrefslogtreecommitdiffstats
path: root/test/SemaCXX/elaborated-type-specifier.cpp
blob: 70478e0f32c4718e7fce1f9b46a2939ad4834bee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// RUN: clang-cc -fsyntax-only -verify %s

// Test the use of elaborated-type-specifiers to inject the names of
// structs (or classes or unions) into an outer scope as described in
// C++ [basic.scope.pdecl]p5.
typedef struct S1 {
  union {
    struct S2 *x;
    struct S3 *y;
  };
} S1;

bool test_elab(S1 *s1, struct S2 *s2, struct S3 *s3) {
  if (s1->x == s2) return true;
  if (s1->y == s3) return true;
  return false;
}

namespace NS {
  class X {
  public:
    void test_elab2(struct S4 *s4);
  };

  void X::test_elab2(S4 *s4) { }
}

void test_X_elab(NS::X x) {
  struct S4 *s4 = 0;
  x.test_elab2(s4); // expected-error{{incompatible type passing 'struct S4 *', expected 'struct NS::S4 *'}}
}

namespace NS {
  S4 *get_S4();
}

void test_S5_scope() {
  S4 *s4; // expected-error{{use of undeclared identifier 'S4'}}
}

int test_funcparam_scope(struct S5 * s5) {
  struct S5 { int y; } *s5_2 = 0;
  if (s5 == s5_2) return 1; // expected-error {{comparison of distinct pointer types ('struct S5 *' and 'struct S5 *')}}
  return 0;
}


OpenPOWER on IntegriCloud