summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaOpenCL
diff options
context:
space:
mode:
authorRichard Smith <richard@metafoo.co.uk>2019-12-19 11:15:47 -0800
committerRichard Smith <richard@metafoo.co.uk>2019-12-19 18:37:55 -0800
commitde21704ba96fa80d3e9402f12c6505917a3885f4 (patch)
tree4c6f76c59c3367f408c4ab4c881a28cb150859a3 /clang/test/SemaOpenCL
parenta77a290a4dbb1db2de4cf48c0599f8e3a3c86c53 (diff)
downloadbcm5719-llvm-de21704ba96fa80d3e9402f12c6505917a3885f4.tar.gz
bcm5719-llvm-de21704ba96fa80d3e9402f12c6505917a3885f4.zip
CWG2352: Allow qualification conversions during reference binding.
The language wording change forgot to update overload resolution to rank implicit conversion sequences based on qualification conversions in reference bindings. The anticipated resolution for that oversight is implemented here -- we order candidates based on qualification conversion, not only on top-level cv-qualifiers. For OpenCL/C++, this allows reference binding between pointers with differing (nested) address spaces. This makes the behavior of reference binding consistent with that of implicit pointer conversions, as is the purpose of this change, but that pre-existing behavior for pointer conversions is itself probably not correct. In any case, it's now consistently the same behavior and implemented in only one place.
Diffstat (limited to 'clang/test/SemaOpenCL')
-rw-r--r--clang/test/SemaOpenCL/address-spaces-conversions-cl2.0.cl18
1 files changed, 10 insertions, 8 deletions
diff --git a/clang/test/SemaOpenCL/address-spaces-conversions-cl2.0.cl b/clang/test/SemaOpenCL/address-spaces-conversions-cl2.0.cl
index a97565f3a2e..0209e1ea24d 100644
--- a/clang/test/SemaOpenCL/address-spaces-conversions-cl2.0.cl
+++ b/clang/test/SemaOpenCL/address-spaces-conversions-cl2.0.cl
@@ -501,12 +501,9 @@ void test_pointer_chains() {
// Case 1:
// * address spaces of corresponded most outer pointees overlaps, their canonical types are equal
// * CVR, address spaces and canonical types of the rest of pointees are equivalent.
+ var_as_as_int = var_asc_as_int;
var_as_as_int = 0 ? var_as_as_int : var_asc_as_int;
-#if __OPENCL_CPP_VERSION__
-#ifdef GENERIC
-// expected-error@-3{{incompatible operand types ('__generic int *__generic *' and '__generic int *__local *')}}
-#endif
-#endif
+
// Case 2: Corresponded inner pointees has non-overlapping address spaces.
var_as_as_int = 0 ? var_as_as_int : var_asc_asn_int;
#if !__OPENCL_CPP_VERSION__
@@ -516,12 +513,17 @@ void test_pointer_chains() {
#endif
// Case 3: Corresponded inner pointees has overlapping but not equivalent address spaces.
+ // FIXME: Should this really be allowed in C++ mode?
+ var_as_as_int = var_asc_asc_int;
+#if !__OPENCL_CPP_VERSION__
#ifdef GENERIC
+// expected-error@-3 {{assigning '__local int *__local *' to '__generic int *__generic *' changes address space of nested pointer}}
+#endif
+#endif
var_as_as_int = 0 ? var_as_as_int : var_asc_asc_int;
#if !__OPENCL_CPP_VERSION__
-// expected-warning-re@-2{{pointer type mismatch ('__{{(generic|global|constant)}} int *__{{(generic|global|constant)}} *' and '__{{(local|global|constant)}} int *__{{(local|global|constant)}} *')}}
-#else
-// expected-error-re@-4{{incompatible operand types ('__{{generic|global|constant}} int *__{{generic|global|constant}} *' and '__{{local|global|constant}} int *__{{local|global|constant}} *')}}
+#ifdef GENERIC
+// expected-warning@-3{{pointer type mismatch ('__generic int *__generic *' and '__local int *__local *')}}
#endif
#endif
}
OpenPOWER on IntegriCloud