summaryrefslogtreecommitdiffstats
path: root/clang/test
diff options
context:
space:
mode:
Diffstat (limited to 'clang/test')
-rw-r--r--clang/test/CXX/drs/dr23xx.cpp35
-rw-r--r--clang/test/CXX/drs/dr4xx.cpp11
-rw-r--r--clang/test/SemaCXX/ref-init-ambiguous.cpp24
-rw-r--r--clang/test/SemaObjCXX/arc-overloading.mm30
-rw-r--r--clang/test/SemaOpenCL/address-spaces-conversions-cl2.0.cl18
5 files changed, 104 insertions, 14 deletions
diff --git a/clang/test/CXX/drs/dr23xx.cpp b/clang/test/CXX/drs/dr23xx.cpp
index 763abd5368e..85f59207460 100644
--- a/clang/test/CXX/drs/dr23xx.cpp
+++ b/clang/test/CXX/drs/dr23xx.cpp
@@ -1,12 +1,41 @@
-// RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors 2>&1
// RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors 2>&1 | FileCheck %s
// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors 2>&1 | FileCheck %s
// RUN: %clang_cc1 -std=c++17 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors 2>&1 | FileCheck %s
// RUN: %clang_cc1 -std=c++2a %s -verify -fexceptions -fcxx-exceptions -pedantic-errors 2>&1 | FileCheck %s
-#if __cplusplus <= 201103L
-// expected-no-diagnostics
+namespace dr2352 { // dr2352: 10
+ int **p;
+ const int *const *const &f1() { return p; }
+ int *const *const &f2() { return p; }
+ int **const &f3() { return p; }
+
+ const int **const &f4() { return p; } // expected-error {{reference to type 'const int **const' could not bind to an lvalue of type 'int **'}}
+ const int *const *&f5() { return p; } // expected-error {{binding reference of type 'const int *const *' to value of type 'int **' not permitted due to incompatible qualifiers}}
+
+ // FIXME: We permit this as a speculative defect resolution, allowing
+ // qualification conversions when forming a glvalue conditional expression.
+ const int * const * const q = 0;
+ __typeof(&(true ? p : q)) x = &(true ? p : q);
+
+ // FIXME: Should we compute the composite pointer type here and produce an
+ // lvalue of type 'const int *const * const'?
+ const int * const * r;
+ void *y = &(true ? p : r); // expected-error {{rvalue of type 'const int *const *'}}
+
+ // FIXME: We order these as a speculative defect resolution.
+ void f(const int * const * const &r);
+#if __cplusplus >= 201103L
+ constexpr
#endif
+ int *const *const &f(int * const * const &r) { return r; }
+
+ // No temporary is created here.
+ int *const *const &check_f = f(p);
+#if __cplusplus >= 201103L
+ static_assert(&p == &check_f, "");
+#endif
+}
namespace dr2353 { // dr2353: 9
struct X {
diff --git a/clang/test/CXX/drs/dr4xx.cpp b/clang/test/CXX/drs/dr4xx.cpp
index 8eeb7715cad..d37ece6cb88 100644
--- a/clang/test/CXX/drs/dr4xx.cpp
+++ b/clang/test/CXX/drs/dr4xx.cpp
@@ -486,14 +486,21 @@ namespace dr433 { // dr433: yes
S<int> s;
}
-namespace dr434 { // dr434: yes
+namespace dr434 { // dr434: sup 2352
void f() {
const int ci = 0;
int *pi = 0;
- const int *&rpci = pi; // expected-error {{cannot bind}}
+ const int *&rpci = pi; // expected-error {{incompatible qualifiers}}
+ const int * const &rcpci = pi; // OK
rpci = &ci;
*pi = 1;
}
+
+#if __cplusplus >= 201103L
+ int *pi = 0;
+ const int * const &rcpci = pi;
+ static_assert(&rcpci == &pi, "");
+#endif
}
// dr435: na
diff --git a/clang/test/SemaCXX/ref-init-ambiguous.cpp b/clang/test/SemaCXX/ref-init-ambiguous.cpp
index ce47e10c9ae..7e1a3bc5794 100644
--- a/clang/test/SemaCXX/ref-init-ambiguous.cpp
+++ b/clang/test/SemaCXX/ref-init-ambiguous.cpp
@@ -25,4 +25,26 @@ const E2 & re(C c) {
return c; // expected-error {{reference initialization of type 'const E2 &' with initializer of type 'C' is ambiguous}}
}
-
+namespace CWG2352 {
+ void f(const int * const &) = delete;
+ void f(int *);
+
+ void g(int * &);
+ void g(const int *) = delete;
+
+ void h1(int *const * const &);
+ void h1(const int *const *) = delete;
+ void h2(const int *const * const &) = delete;
+ void h2(int *const *);
+
+ void test() {
+ int *x;
+ // Under CWG2352, this became ambiguous. We order by qualification
+ // conversion even when comparing a reference binding to a
+ // non-reference-binding.
+ f(x);
+ g(x);
+ h1(&x);
+ h2(&x);
+ }
+}
diff --git a/clang/test/SemaObjCXX/arc-overloading.mm b/clang/test/SemaObjCXX/arc-overloading.mm
index 3ac9c51293b..910b5c7be97 100644
--- a/clang/test/SemaObjCXX/arc-overloading.mm
+++ b/clang/test/SemaObjCXX/arc-overloading.mm
@@ -174,6 +174,36 @@ void test_f9() {
const __autoreleasing id& ar4 = weak_a;
}
+int &f10(__strong id *&); // expected-note 2{{not viable: no known conversion}}
+float &f10(__autoreleasing id *&); // expected-note 2{{not viable: no known conversion}}
+
+void test_f10() {
+ __strong id *strong_id;
+ __weak id *weak_id;
+ __autoreleasing id *autoreleasing_id;
+ __unsafe_unretained id *unsafe_id;
+
+ int &ir1 = f10(strong_id);
+ float &fr1 = f10(autoreleasing_id);
+ float &fr2 = f10(unsafe_id); // expected-error {{no match}}
+ float &fr2a = f10(weak_id); // expected-error {{no match}}
+}
+
+int &f11(__strong id *const &); // expected-note {{not viable: 1st argument ('__weak id *') has __weak ownership, but parameter has __strong ownership}}
+float &f11(const __autoreleasing id *const &); // expected-note {{not viable: 1st argument ('__weak id *') has __weak ownership, but parameter has __autoreleasing ownership}}
+
+void test_f11() {
+ __strong id *strong_id;
+ __weak id *weak_id;
+ __autoreleasing id *autoreleasing_id;
+ __unsafe_unretained id *unsafe_id;
+
+ int &ir1 = f11(strong_id);
+ float &fr1 = f11(autoreleasing_id);
+ float &fr2 = f11(unsafe_id);
+ float &fr2a = f11(weak_id); // expected-error {{no match}}
+}
+
// rdar://9790531
void f9790531(void *inClientData); // expected-note {{candidate function not viable: cannot implicitly convert argument of type 'MixerEQGraphTestDelegate *const __strong' to 'void *' for 1st argument under ARC}}
void f9790531_1(struct S*inClientData); // expected-note {{candidate function not viable}}
diff --git a/clang/test/SemaOpenCL/address-spaces-conversions-cl2.0.cl b/clang/test/SemaOpenCL/address-spaces-conversions-cl2.0.cl
index c46e4e08a2c..14f7cf3a0e7 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 *__private' to '__generic int *__generic *__private' 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