summaryrefslogtreecommitdiffstats
path: root/test/CXX/expr/expr.prim/expr.prim.general/p8-0x.cpp
blob: 5b3a004056b52b82994de06fda09e643b0db7cba (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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s

struct global {
};

namespace PR10127 {
  struct outer {
    struct middle {
      struct inner {
        int func();
        int i;
      };
      struct inner2 {
      };
      struct inner3 {
      };
      int mfunc();
    };
    typedef int td_int;
  };

  struct str {
    operator decltype(outer::middle::inner()) ();
    operator decltype(outer::middle())::inner2 ();
    operator decltype(outer())::middle::inner3 ();
    str(int (decltype(outer::middle::inner())::*n)(),
             int (decltype(outer::middle())::inner::*o)(),
             int (decltype(outer())::middle::inner::*p)());
  };

  decltype(outer::middle::inner()) a;
  void scope() {
    a.decltype(outer::middle())::mfunc(); // expected-error{{'PR10127::outer::middle::mfunc' is not a member of class 'decltype(outer::middle::inner())'}}
    a.decltype(outer::middle::inner())::func();
    a.decltype(outer::middle())::inner::func();
    a.decltype(outer())::middle::inner::func();

    a.decltype(outer())::middle::inner::~inner();

    decltype(outer())::middle::inner().func();
  }
  decltype(outer::middle())::inner b;
  decltype(outer())::middle::inner c;
  decltype(outer())::fail d; // expected-error{{no type named 'fail' in 'PR10127::outer'}}
  decltype(outer())::fail::inner e; // expected-error{{no member named 'fail' in 'PR10127::outer'}}
  decltype()::fail f; // expected-error{{expected expression}}
  decltype()::middle::fail g; // expected-error{{expected expression}}
  
  decltype(int()) h;
  decltype(int())::PR10127::outer i; // expected-error{{'decltype(int())' (aka 'int') is not a class, namespace, or scoped enumeration}}
  decltype(int())::global j; // expected-error{{'decltype(int())' (aka 'int') is not a class, namespace, or scoped enumeration}}
  
  outer::middle k = decltype(outer())::middle();
  outer::middle::inner l = decltype(outer())::middle::inner();

  template<typename T>
  struct templ {
    typename decltype(T())::middle::inner x; // expected-error{{type 'decltype(int())' (aka 'int') cannot be used prior to '::' because it has no members}}
  };

  template class templ<int>; // expected-note{{in instantiation of template class 'PR10127::templ<int>' requested here}}
  template class templ<outer>;

  enum class foo {
    bar,
    baz
  };
  
  foo m = decltype(foo::bar)::baz;

  enum E {
  };
  struct bar {
    enum E : decltype(outer())::td_int(4);
    enum F : decltype(outer())::td_int;
    enum G : decltype; // expected-error{{expected '(' after 'decltype'}}
  };
}