diff options
author | Erich Keane <erich.keane@intel.com> | 2018-07-13 19:46:04 +0000 |
---|---|---|
committer | Erich Keane <erich.keane@intel.com> | 2018-07-13 19:46:04 +0000 |
commit | 12e2fde436d38782477f681dbf3fc83b8095e188 (patch) | |
tree | 86442dc143d91a91cbeaddee88bbe3fa6a8c0bc5 /test/SemaCXX/vector.cpp | |
parent | d119a80874f84aed19417020a5ab04d4568f1743 (diff) |
PR15730/PR16986 Allow dependently typed vector_size types.
As listed in the above PRs, vector_size doesn't allow
dependent types/values. This patch introduces a new
DependentVectorType to handle a VectorType that has a dependent
size or type.
In the future, ALL the vector-types should be able to create one
of these to handle dependent types/sizes as well. For example,
DependentSizedExtVectorType could likely be switched to just use
this instead, though that is left as an exercise for the future.
Differential Revision: https://reviews.llvm.org/D49045
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@337036 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/SemaCXX/vector.cpp')
-rw-r--r-- | test/SemaCXX/vector.cpp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/test/SemaCXX/vector.cpp b/test/SemaCXX/vector.cpp index 8fe24a32c8..56a8a6db5b 100644 --- a/test/SemaCXX/vector.cpp +++ b/test/SemaCXX/vector.cpp @@ -291,3 +291,46 @@ const int &reference_to_vec_element = vi4(1).x; // PR12649 typedef bool bad __attribute__((__vector_size__(16))); // expected-error {{invalid vector element type 'bool'}} + +namespace Templates { +template <typename Elt, unsigned Size> +struct TemplateVectorType { + typedef Elt __attribute__((__vector_size__(Size))) type; +}; + +template <int N, typename T> +struct PR15730 { + typedef T __attribute__((vector_size(N * sizeof(T)))) type; + typedef T __attribute__((vector_size(8192))) type2; + typedef T __attribute__((vector_size(3))) type3; +}; + +void Init() { + const TemplateVectorType<float, 32>::type Works = {}; + const TemplateVectorType<int, 32>::type Works2 = {}; + // expected-error@298 {{invalid vector element type 'bool'}} + // expected-note@+1 {{in instantiation of template class 'Templates::TemplateVectorType<bool, 32>' requested here}} + const TemplateVectorType<bool, 32>::type NoBool; + // expected-error@298 {{invalid vector element type 'int __attribute__((ext_vector_type(4)))' (vector of 4 'int' values)}} + // expected-note@+1 {{in instantiation of template class 'Templates::TemplateVectorType<int __attribute__((ext_vector_type(4))), 32>' requested here}} + const TemplateVectorType<vi4, 32>::type NoComplex; + // expected-error@298 {{vector size not an integral multiple of component size}} + // expected-note@+1 {{in instantiation of template class 'Templates::TemplateVectorType<int, 33>' requested here}} + const TemplateVectorType<int, 33>::type BadSize; + // expected-error@298 {{vector size too large}} + // expected-note@+1 {{in instantiation of template class 'Templates::TemplateVectorType<int, 8192>' requested here}} + const TemplateVectorType<int, 8192>::type TooLarge; + // expected-error@298 {{zero vector size}} + // expected-note@+1 {{in instantiation of template class 'Templates::TemplateVectorType<int, 0>' requested here}} + const TemplateVectorType<int, 0>::type Zero; + + // expected-error@304 {{vector size too large}} + // expected-error@305 {{vector size not an integral multiple of component size}} + // expected-note@+1 {{in instantiation of template class 'Templates::PR15730<8, int>' requested here}} + const PR15730<8, int>::type PR15730_1 = {}; + // expected-error@304 {{vector size too large}} + // expected-note@+1 {{in instantiation of template class 'Templates::PR15730<8, char>' requested here}} + const PR15730<8, char>::type2 PR15730_2 = {}; +} + +} // namespace Templates |