summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaTemplate/instantiate-field.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-03-11 18:59:21 +0000
committerDouglas Gregor <dgregor@apple.com>2009-03-11 18:59:21 +0000
commit1efa437be6a6cf30520ce86448d422ea9d78d627 (patch)
treeb393af253f0b32ced3c7de628cee350cbf34f4f7 /clang/test/SemaTemplate/instantiate-field.cpp
parent25c6a46a812f2e24ceb08c493703878c68abfde8 (diff)
downloadbcm5719-llvm-1efa437be6a6cf30520ce86448d422ea9d78d627.tar.gz
bcm5719-llvm-1efa437be6a6cf30520ce86448d422ea9d78d627.zip
Implement basic template instantiation for fields. Reshuffle checking
for FieldDecls so that the parser and the template instantiation make use of the same semantic checking module. llvm-svn: 66685
Diffstat (limited to 'clang/test/SemaTemplate/instantiate-field.cpp')
-rw-r--r--clang/test/SemaTemplate/instantiate-field.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/clang/test/SemaTemplate/instantiate-field.cpp b/clang/test/SemaTemplate/instantiate-field.cpp
new file mode 100644
index 00000000000..dbfbd470600
--- /dev/null
+++ b/clang/test/SemaTemplate/instantiate-field.cpp
@@ -0,0 +1,28 @@
+// RUN: clang -fsyntax-only -verify %s
+
+template<typename T>
+struct X {
+ int x;
+ T y; // expected-error{{data member instantiated with function type}}
+ T* z;
+ T bitfield : 12; // expected-error{{bit-field 'bitfield' has non-integral type 'float'}} \
+ // expected-error{{data member instantiated with function type}}
+
+ mutable T x2; // expected-error{{data member instantiated with function type}}
+};
+
+void test1(const X<int> *xi) {
+ int i1 = xi->x;
+ const int &i2 = xi->y;
+ int* ip1 = xi->z;
+ int i3 = xi->bitfield;
+ xi->x2 = 17;
+}
+
+void test2(const X<float> *xf) {
+ (void)xf->x; // expected-note{{in instantiation of template class 'struct X<float>' requested here}}
+}
+
+void test3(const X<int(int)> *xf) {
+ (void)xf->x; // expected-note{{in instantiation of template class 'struct X<int (int)>' requested here}}
+}
OpenPOWER on IntegriCloud