[PATCH] D103252: [C++4OpenCL] Fix missing address space on implicit move assignment operator
Ole Strohm via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu May 27 07:36:37 PDT 2021
olestrohm created this revision.
olestrohm added reviewers: Anastasia, svenvh.
olestrohm added a project: clang.
Herald added subscribers: ldrumm, yaxunl.
olestrohm requested review of this revision.
Herald added a subscriber: cfe-commits.
This fixes the missing address space on `this` in the implicit move assignment operator.
The function called here is an abstraction around the lines that have been removed, and also sets the address space correctly.
This is copied from CopyConstructor, CopyAssignment and MoveConstructor, all of which use this new function, and now
MoveAssignment is has been aligned to use the same method.
I also added a new test file to check the output AST. If there's a better place for this test I will move it there.
Fixes: PR50259
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D103252
Files:
clang/lib/Sema/SemaDeclCXX.cpp
clang/test/SemaOpenCLCXX/addrspace-assignment.clcpp
Index: clang/test/SemaOpenCLCXX/addrspace-assignment.clcpp
===================================================================
--- /dev/null
+++ clang/test/SemaOpenCLCXX/addrspace-assignment.clcpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 %s -ast-dump -pedantic -verify | FileCheck %s
+
+
+// CHECK: CXXConstructorDecl {{.*}} implicit {{.*}} Implicit 'void (const __generic Implicit &) __generic'
+// CHECK: CXXConstructorDecl {{.*}} implicit {{.*}} Implicit 'void (__generic Implicit &&) __generic'
+// CHECK: CXXMethodDecl {{.*}} implicit {{.*}} operator= '__generic Implicit &(const __generic Implicit &) __generic'
+// CHECK: CXXMethodDecl {{.*}} implicit {{.*}} operator= '__generic Implicit &(__generic Implicit &&) __generic'
+// expected-note at +2{{candidate function (the implicit copy assignment operator) not viable: no known conversion from 'int' to 'const __generic Implicit' for 1st argument}}
+// expected-note at +1{{candidate function (the implicit move assignment operator) not viable: no known conversion from 'int' to '__generic Implicit' for 1st argument}}
+struct Implicit {};
+
+void f() {
+ Implicit i;
+ i = 10; // expected-error{{no viable overloaded '='}}
+}
+
Index: clang/lib/Sema/SemaDeclCXX.cpp
===================================================================
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -14299,10 +14299,7 @@
/* Diagnose */ false);
}
- // Build an exception specification pointing back at this member.
- FunctionProtoType::ExtProtoInfo EPI =
- getImplicitMethodEPI(*this, MoveAssignment);
- MoveAssignment->setType(Context.getFunctionType(RetType, ArgType, EPI));
+ setupImplicitSpecialMemberType(MoveAssignment, RetType, ArgType);
// Add the parameter to the operator.
ParmVarDecl *FromParam = ParmVarDecl::Create(Context, MoveAssignment,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D103252.348259.patch
Type: text/x-patch
Size: 1883 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210527/f8aa3c67/attachment.bin>
More information about the cfe-commits
mailing list