aboutsummaryrefslogtreecommitdiff
path: root/test/SemaCXX/nested-name-spec-locations.cpp
blob: 996b1cf50ac8088f5338febb50b990ea1fbebc4d (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
79
80
81
82
83
84
85
86
87
// RUN: %clang_cc1 -fsyntax-only -verify %s

// Note: the formatting in this test case is intentionally funny, with
// nested-name-specifiers stretched out vertically so that we can
// match up diagnostics per-line and still verify that we're getting
// good source-location information.

namespace outer {
  namespace inner {
    template<typename T>
    struct X0 {
    };
  }
}

template<typename T>
struct add_reference {
  typedef T& type;
};

namespace outer_alias = outer;

template<typename T>
struct UnresolvedUsingValueDeclTester {
  using outer::inner::X0<
          typename add_reference<T>::type 
    * // expected-error{{declared as a pointer to a reference of type}}
        >::value;
};

UnresolvedUsingValueDeclTester<int> UnresolvedUsingValueDeclCheck; // expected-note{{in instantiation of template class}}

template<typename T>
struct UnresolvedUsingTypenameDeclTester {
  using outer::inner::X0<
          typename add_reference<T>::type 
    * // expected-error{{declared as a pointer to a reference of type}}
        >::value;
};

UnresolvedUsingTypenameDeclTester<int> UnresolvedUsingTypenameDeclCheck; // expected-note{{in instantiation of template class}}


template<typename T, typename U>
struct PseudoDestructorExprTester {
  void f(T *t) {
    t->T::template Inner<typename add_reference<U>::type 
      * // expected-error{{as a pointer to a reference of type}}
      >::Blarg::~Blarg();
  }
};

struct HasInnerTemplate {
  template<typename T>
  struct Inner;

  typedef HasInnerTemplate T;
};

void PseudoDestructorExprCheck(
                    PseudoDestructorExprTester<HasInnerTemplate, float> tester) {
  tester.f(0); // expected-note{{in instantiation of member function}}
}

template<typename T>
struct DependentScopedDeclRefExpr {
  void f() {
    outer_alias::inner::X0<typename add_reference<T>::type 
      * // expected-error{{as a pointer to a reference of type}}
      >::value = 17;
  }
};

void DependentScopedDeclRefExprCheck(DependentScopedDeclRefExpr<int> t) {
  t.f(); // expected-note{{in instantiation of member function}}
}


template<typename T>
struct TypenameTypeTester {
  typedef typename outer::inner::X0<
          typename add_reference<T>::type 
    * // expected-error{{declared as a pointer to a reference of type}}
        >::type type;
};

TypenameTypeTester<int> TypenameTypeCheck; // expected-note{{in instantiation of template class}}