diff options
| author | Douglas Gregor <dgregor@apple.com> | 2009-05-22 21:13:27 +0000 |
|---|---|---|
| committer | Douglas Gregor <dgregor@apple.com> | 2009-05-22 21:13:27 +0000 |
| commit | a8db954f241b340b9ce1466ea3c4a17969573af5 (patch) | |
| tree | 2189373c16d1174b49fafc5f439c6df83a75926c /clang/test/SemaTemplate/instantiate-expr-4.cpp | |
| parent | c996521508210a67a2f5e6ef3c0d78a0bb273d4b (diff) | |
| download | bcm5719-llvm-a8db954f241b340b9ce1466ea3c4a17969573af5.tar.gz bcm5719-llvm-a8db954f241b340b9ce1466ea3c4a17969573af5.zip | |
Representation of and template instantiation for member
expressions. This change introduces another AST node,
CXXUnresolvedMemberExpr, that captures member references (x->m, x.m)
when the base of the expression (the "x") is type-dependent, and we
therefore cannot resolve the member reference yet.
Note that our parsing of member references for C++ is still quite
poor, e.g., we don't handle x->Base::m or x->operator int.
llvm-svn: 72281
Diffstat (limited to 'clang/test/SemaTemplate/instantiate-expr-4.cpp')
| -rw-r--r-- | clang/test/SemaTemplate/instantiate-expr-4.cpp | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/clang/test/SemaTemplate/instantiate-expr-4.cpp b/clang/test/SemaTemplate/instantiate-expr-4.cpp index 09d574176ac..0f2bb93f413 100644 --- a/clang/test/SemaTemplate/instantiate-expr-4.cpp +++ b/clang/test/SemaTemplate/instantiate-expr-4.cpp @@ -178,3 +178,63 @@ struct InitList2 { template struct InitList2<APair, int*, float*>; template struct InitList2<APair, int*, double*>; // expected-note{{instantiation}} + +// --------------------------------------------------------------------- +// member references +// --------------------------------------------------------------------- +template<typename T, typename Result> +struct DotMemRef0 { + void f(T t) { + Result result = t.m; // expected-error{{cannot be initialized}} + } +}; + +struct MemInt { + int m; +}; + +struct InheritsMemInt : MemInt { }; + +struct MemIntFunc { + static int m(int); +}; + +template struct DotMemRef0<MemInt, int&>; +template struct DotMemRef0<InheritsMemInt, int&>; +template struct DotMemRef0<MemIntFunc, int (*)(int)>; +template struct DotMemRef0<MemInt, float&>; // expected-note{{instantiation}} + +template<typename T, typename Result> +struct ArrowMemRef0 { + void f(T t) { + Result result = t->m; // expected-error 2{{cannot be initialized}} + } +}; + +template<typename T> +struct ArrowWrapper { + T operator->(); +}; + +template struct ArrowMemRef0<MemInt*, int&>; +template struct ArrowMemRef0<InheritsMemInt*, int&>; +template struct ArrowMemRef0<MemIntFunc*, int (*)(int)>; +template struct ArrowMemRef0<MemInt*, float&>; // expected-note{{instantiation}} + +template struct ArrowMemRef0<ArrowWrapper<MemInt*>, int&>; +template struct ArrowMemRef0<ArrowWrapper<InheritsMemInt*>, int&>; +template struct ArrowMemRef0<ArrowWrapper<MemIntFunc*>, int (*)(int)>; +template struct ArrowMemRef0<ArrowWrapper<MemInt*>, float&>; // expected-note{{instantiation}} +template struct ArrowMemRef0<ArrowWrapper<ArrowWrapper<MemInt*> >, int&>; + +// FIXME: we should be able to return a MemInt without the reference! +MemInt &createMemInt(int); + +template<int N> +struct NonDepMemberExpr0 { + void f() { + createMemInt(N).m = N; + } +}; + +template struct NonDepMemberExpr0<0>; |

