summaryrefslogtreecommitdiffstats
path: root/test/SemaTemplate/typename-specifier-2.cpp
blob: 551cac3168b299eb11632b99befd2a4d6606b6ee (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
// RUN: %clang_cc1 -fsyntax-only -verify %s

template<typename MetaFun, typename T>
struct bind_metafun {
  typedef typename MetaFun::template apply<T> type;
};

struct add_pointer {
  template<typename T>
  struct apply {
    typedef T* type;
  };
};

int i;
// FIXME: if we make the declarator below a pointer (e.g., with *ip),
// the error message isn't so good because we don't get the handy
// 'aka' telling us that we're dealing with an int**. Should we fix
// getDesugaredType to dig through pointers and such?
bind_metafun<add_pointer, int>::type::type ip = &i;
bind_metafun<add_pointer, float>::type::type fp = &i; // expected-error{{cannot initialize a variable of type 'bind_metafun<add_pointer, float>::type::type' (aka 'float *') with an rvalue of type 'int *'}}


template<typename T>
struct extract_type_type {
  typedef typename T::type::type t;
};

double d;
extract_type_type<bind_metafun<add_pointer, double> >::t dp = &d;