diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-03-24 19:52:54 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-03-24 19:52:54 +0000 |
commit | e7450f5dbd5bed63b8ef9db86350a8fc3db011e8 (patch) | |
tree | 61d7b8565db05760fb505fa9c25af4ed13e48bbf /test/SemaTemplate/instantiate-complete.cpp | |
parent | 6256d3654533547a7996170647c21a859cb441e1 (diff) |
Make sure to use RequireCompleteType rather than testing for
incomplete types. RequireCompleteType is needed when the type may be
completed by instantiating a template.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67643 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/SemaTemplate/instantiate-complete.cpp')
-rw-r--r-- | test/SemaTemplate/instantiate-complete.cpp | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/test/SemaTemplate/instantiate-complete.cpp b/test/SemaTemplate/instantiate-complete.cpp new file mode 100644 index 0000000000..7b4373538d --- /dev/null +++ b/test/SemaTemplate/instantiate-complete.cpp @@ -0,0 +1,47 @@ +// RUN: clang-cc -fsyntax-only -verify %s + +// Tests various places where requiring a complete type involves +// instantiation of that type. + +template<typename T> +struct X { + X(T); + + T f; // expected-error{{data member instantiated with function type 'float (int)'}} \ + // expected-error{{data member instantiated with function type 'int (int)'}} \ + // expected-error{{data member instantiated with function type 'char (char)'}} \ + // expected-error{{data member instantiated with function type 'short (short)'}} \ + // expected-error{{data member instantiated with function type 'float (float)'}} \ + // expected-error{{data member instantiated with function type 'long (long)'}} +}; + +X<int> f() { return 0; } + +struct XField { + X<float(int)> xf; // expected-note{{in instantiation of template class 'struct X<float (int)>' requested here}} +}; + +void test_subscript(X<double> *ptr1, X<int(int)> *ptr2, int i) { + (void)ptr1[i]; + (void)ptr2[i]; // expected-note{{in instantiation of template class 'struct X<int (int)>' requested here}} +} + +void test_arith(X<signed char> *ptr1, X<unsigned char> *ptr2, + X<char(char)> *ptr3, X<short(short)> *ptr4) { + (void)(ptr1 + 5); + // FIXME: if I drop the ')' after void, below, it still parses (!) + (void)(5 + ptr2); + (void)(ptr3 + 5); // expected-note{{in instantiation of template class 'struct X<char (char)>' requested here}} + (void)(5 + ptr4); // expected-note{{in instantiation of template class 'struct X<short (short)>' requested here}} +} + +void test_new() { + (void)new X<float>(0); + (void)new X<float(float)>; // expected-note{{in instantiation of template class 'struct X<float (float)>' requested here}} +} + +void test_memptr(X<long> *p1, long X<long>::*pm1, + X<long(long)> *p2, long (X<long(long)>::*pm2)(long)) { + (void)(p1->*pm1); + (void)(p2->*pm2); // expected-note{{in instantiation of template class 'struct X<long (long)>' requested here}} +} |