summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaCXX/vector.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/test/SemaCXX/vector.cpp')
-rw-r--r--clang/test/SemaCXX/vector.cpp82
1 files changed, 62 insertions, 20 deletions
diff --git a/clang/test/SemaCXX/vector.cpp b/clang/test/SemaCXX/vector.cpp
index 295e1e17323..67e5a94cb10 100644
--- a/clang/test/SemaCXX/vector.cpp
+++ b/clang/test/SemaCXX/vector.cpp
@@ -1,6 +1,8 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify %s
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify -std=c++98 %s
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify -std=c++11 %s
+// RUN: %clang_cc1 -flax-vector-conversions=all -triple x86_64-apple-darwin10 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -flax-vector-conversions=all -triple x86_64-apple-darwin10 -fsyntax-only -verify -std=c++98 %s
+// RUN: %clang_cc1 -flax-vector-conversions=all -triple x86_64-apple-darwin10 -fsyntax-only -verify -std=c++11 %s
+// RUN: %clang_cc1 -flax-vector-conversions=integer -triple x86_64-apple-darwin10 -fsyntax-only -verify %s -DNO_LAX_FLOAT
+// RUN: %clang_cc1 -flax-vector-conversions=none -triple x86_64-apple-darwin10 -fsyntax-only -verify %s -DNO_LAX_FLOAT -DNO_LAX_INT
typedef char char16 __attribute__ ((__vector_size__ (16)));
typedef long long longlong16 __attribute__ ((__vector_size__ (16)));
@@ -8,13 +10,19 @@ typedef char char16_e __attribute__ ((__ext_vector_type__ (16)));
typedef long long longlong16_e __attribute__ ((__ext_vector_type__ (2)));
// Test overloading and function calls with vector types.
-void f0(char16);
+void f0(char16); // expected-note 0+{{candidate}}
void f0_test(char16 c16, longlong16 ll16, char16_e c16e, longlong16_e ll16e) {
f0(c16);
f0(ll16);
+#ifdef NO_LAX_INT
+ // expected-error@-2 {{no matching function}}
+#endif
f0(c16e);
f0(ll16e);
+#ifdef NO_LAX_INT
+ // expected-error@-2 {{no matching function}}
+#endif
}
int &f1(char16);
@@ -27,12 +35,14 @@ void f1_test(char16 c16, longlong16 ll16, char16_e c16e, longlong16_e ll16e) {
float &fr2 = f1(ll16e);
}
-void f2(char16_e); // expected-note{{no known conversion from 'longlong16_e' (vector of 2 'long long' values) to 'char16_e' (vector of 16 'char' values) for 1st argument}} \
- // expected-note{{candidate function not viable: no known conversion from 'convertible_to<longlong16_e>' to 'char16_e' (vector of 16 'char' values) for 1st argument}}
+void f2(char16_e); // expected-note 0+{{candidate}}
void f2_test(char16 c16, longlong16 ll16, char16_e c16e, longlong16_e ll16e) {
f2(c16);
f2(ll16);
+#ifdef NO_LAX_INT
+ // expected-error@-2 {{no matching function}}
+#endif
f2(c16e);
f2(ll16e); // expected-error{{no matching function}}
f2('a');
@@ -58,6 +68,11 @@ void conditional(bool Cond, char16 c16, longlong16 ll16, char16_e c16e,
(void)(Cond? c16 : ll16);
(void)(Cond? ll16e : c16e);
(void)(Cond? ll16e : c16);
+#ifdef NO_LAX_INT
+ // expected-error@-4 {{cannot convert}}
+ // expected-error@-4 {{cannot convert}}
+ // expected-error@-4 {{cannot convert}}
+#endif
}
// Test C++ cast'ing of vector types.
@@ -85,9 +100,16 @@ void casts(longlong16 ll16, longlong16_e ll16e) {
// static_cast
(void)static_cast<char16>(ll16);
(void)static_cast<char16_e>(ll16);
+#ifdef NO_LAX_INT
+ // expected-error@-3 {{not allowed}}
+ // expected-error@-3 {{not allowed}}
+#endif
(void)static_cast<longlong16>(ll16);
(void)static_cast<longlong16_e>(ll16);
(void)static_cast<char16>(ll16e);
+#ifdef NO_LAX_INT
+ // expected-error@-2 {{not allowed}}
+#endif
(void)static_cast<char16_e>(ll16e); // expected-error{{static_cast from 'longlong16_e' (vector of 2 'long long' values) to 'char16_e' (vector of 16 'char' values) is not allowed}}
(void)static_cast<longlong16>(ll16e);
(void)static_cast<longlong16_e>(ll16e);
@@ -121,10 +143,19 @@ void test_implicit_conversions(bool Cond, char16 c16, longlong16 ll16,
convertible_to<char16_e&> rto_c16e) {
f0(to_c16);
f0(to_ll16);
+#ifdef NO_LAX_INT
+ // expected-error@-2 {{no matching function}}
+#endif
f0(to_c16e);
f0(to_ll16e);
+#ifdef NO_LAX_INT
+ // expected-error@-2 {{no matching function}}
+#endif
f2(to_c16);
f2(to_ll16);
+#ifdef NO_LAX_INT
+ // expected-error@-2 {{no matching function}}
+#endif
f2(to_c16e);
f2(to_ll16e); // expected-error{{no matching function}}
@@ -193,6 +224,10 @@ void test_implicit_conversions(bool Cond, char16 c16, longlong16 ll16,
// These 2 are convertible with -flax-vector-conversions (default)
(void)(Cond? to_c16 : to_ll16);
(void)(Cond? to_c16e : to_ll16e);
+#ifdef NO_LAX_INT
+ // expected-error@-3 {{cannot convert}}
+ // expected-error@-3 {{cannot convert}}
+#endif
}
typedef float fltx2 __attribute__((__vector_size__(8)));
@@ -203,6 +238,10 @@ typedef double dblx4 __attribute__((__vector_size__(32)));
void accept_fltx2(fltx2); // expected-note{{candidate function not viable: no known conversion from 'double' to 'fltx2' (vector of 2 'float' values) for 1st argument}}
void accept_fltx4(fltx4);
void accept_dblx2(dblx2);
+#ifdef NO_LAX_FLOAT
+// expected-note@-3 {{no known conversion}}
+// expected-note@-3 {{no known conversion}}
+#endif
void accept_dblx4(dblx4);
void accept_bool(bool); // expected-note{{candidate function not viable: no known conversion from 'fltx2' (vector of 2 'float' values) to 'bool' for 1st argument}}
@@ -214,9 +253,12 @@ void test(fltx2 fltx2_val, fltx4 fltx4_val, dblx2 dblx2_val, dblx4 dblx4_val) {
accept_dblx4(dblx4_val);
// Same-size conversions
- // FIXME: G++ rejects these conversions, we accept them. Revisit this!
accept_fltx4(dblx2_val);
accept_dblx2(fltx4_val);
+#ifdef NO_LAX_FLOAT
+ // expected-error@-3 {{no matching function}}
+ // expected-error@-3 {{no matching function}}
+#endif
// Conversion to bool.
accept_bool(fltx2_val); // expected-error{{no matching function for call to 'accept_bool'}}
@@ -227,9 +269,9 @@ void test(fltx2 fltx2_val, fltx4 fltx4_val, dblx2 dblx2_val, dblx4 dblx4_val) {
typedef int intx4 __attribute__((__vector_size__(16)));
typedef int inte4 __attribute__((__ext_vector_type__(4)));
-typedef int flte4 __attribute__((__ext_vector_type__(4)));
+typedef float flte4 __attribute__((__ext_vector_type__(4)));
-void test_mixed_vector_types(fltx4 f, intx4 n, flte4 g, flte4 m) {
+void test_mixed_vector_types(fltx4 f, intx4 n, flte4 g, inte4 m) {
(void)(f == g);
(void)(g != f);
(void)(f <= g);
@@ -295,40 +337,40 @@ typedef bool bad __attribute__((__vector_size__(16))); // expected-error {{inva
namespace Templates {
template <typename Elt, unsigned Size>
struct TemplateVectorType {
- typedef Elt __attribute__((__vector_size__(Size))) type;
+ typedef Elt __attribute__((__vector_size__(Size))) type; // #1
};
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;
+ typedef T __attribute__((vector_size(8192))) type2; // #2
+ typedef T __attribute__((vector_size(3))) type3; // #3
};
void Init() {
const TemplateVectorType<float, 32>::type Works = {};
const TemplateVectorType<int, 32>::type Works2 = {};
- // expected-error@298 {{invalid vector element type 'bool'}}
+ // expected-error@#1 {{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-error@#1 {{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-error@#1 {{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-error@#1 {{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-error@#1 {{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-error@#2 {{vector size too large}}
+ // expected-error@#3 {{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-error@#2 {{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 = {};
}
OpenPOWER on IntegriCloud