summaryrefslogtreecommitdiff
path: root/lib/Sema/SemaOverload.cpp
diff options
context:
space:
mode:
authorMarco Antognini <marco.antognini@arm.com>2019-07-18 10:04:18 +0000
committerMarco Antognini <marco.antognini@arm.com>2019-07-18 10:04:18 +0000
commit0e0d37e253bc2b7a450d603dda71f8a3cf27ad24 (patch)
tree873d60a0103126c5664d40b7d086db29a7bf5411 /lib/Sema/SemaOverload.cpp
parentc0abfaad68aedd9c2b1b9f3a1b0ab2809dbf90e0 (diff)
downloadclang-0e0d37e253bc2b7a450d603dda71f8a3cf27ad24.tar.gz
[OpenCL] Improve destructor support in C++ for OpenCL
Summary: This patch does mainly three things: 1. It fixes a false positive error detection in Sema that is similar to D62156. The error happens when explicitly calling an overloaded destructor for different address spaces. 2. It selects the correct destructor when multiple overloads for address spaces are available. 3. It inserts the expected address space cast when invoking a destructor, if needed, and therefore fixes a crash due to the unmet assertion in llvm::CastInst::Create. The following is a reproducer of the three issues: struct MyType { ~MyType() {} ~MyType() __constant {} }; __constant MyType myGlobal{}; kernel void foo() { myGlobal.~MyType(); // 1 and 2. // 1. error: cannot initialize object parameter of type // '__generic MyType' with an expression of type '__constant MyType' // 2. error: no matching member function for call to '~MyType' } kernel void bar() { // 3. The implicit call to the destructor crashes due to: // Assertion `castIsValid(op, S, Ty) && "Invalid cast!"' failed. // in llvm::CastInst::Create. MyType myLocal; } The added test depends on D62413 and covers a few more things than the above reproducer. Subscribers: yaxunl, Anastasia, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64569 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@366422 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaOverload.cpp')
-rw-r--r--lib/Sema/SemaOverload.cpp4
1 files changed, 1 insertions, 3 deletions
diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp
index d8c4ea48eb..f632a4d3bd 100644
--- a/lib/Sema/SemaOverload.cpp
+++ b/lib/Sema/SemaOverload.cpp
@@ -5093,12 +5093,10 @@ TryObjectArgumentInitialization(Sema &S, SourceLocation Loc, QualType FromType,
QualType ClassType = S.Context.getTypeDeclType(ActingContext);
// [class.dtor]p2: A destructor can be invoked for a const, volatile or
// const volatile object.
- Qualifiers Quals;
+ Qualifiers Quals = Method->getMethodQualifiers();
if (isa<CXXDestructorDecl>(Method)) {
Quals.addConst();
Quals.addVolatile();
- } else {
- Quals = Method->getMethodQualifiers();
}
QualType ImplicitParamType = S.Context.getQualifiedType(ClassType, Quals);