[PATCH] D51809: [CUDA][HIP] Fix assertion in LookupSpecialMember
Yaxun Liu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Sep 7 12:36:10 PDT 2018
yaxunl created this revision.
yaxunl added a reviewer: tra.
ShouldDeleteSpecialMember is called upon inherited constructors.
It calls inferCUDATargetForImplicitSpecialMember, which in turn
calls LookupSpecialMember.
LookupSpecialMember expects ConstArg==false for
CXXDefaultConstructor. For inherited constructor with
const arguments, this causes assertion.
This patch fixes that by passing false as ConstArg argument
for CXXDefaultConstructor in ShouldDeleteSpecialMember.
https://reviews.llvm.org/D51809
Files:
lib/Sema/SemaDeclCXX.cpp
test/SemaCUDA/inherited-ctor.cu
Index: test/SemaCUDA/inherited-ctor.cu
===================================================================
--- /dev/null
+++ test/SemaCUDA/inherited-ctor.cu
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+// expected-no-diagnostics
+
+struct A {
+ A(const int &x) {}
+};
+
+struct B : A {
+ using A::A;
+};
+
+struct C {
+ struct B b;
+ C() : b(0) {}
+};
+
+void test() {
+ B b(0);
+ C c;
+}
Index: lib/Sema/SemaDeclCXX.cpp
===================================================================
--- lib/Sema/SemaDeclCXX.cpp
+++ lib/Sema/SemaDeclCXX.cpp
@@ -7187,8 +7187,9 @@
if (getLangOpts().CUDA) {
// We should delete the special member in CUDA mode if target inference
// failed.
- return inferCUDATargetForImplicitSpecialMember(RD, CSM, MD, SMI.ConstArg,
- Diagnose);
+ return inferCUDATargetForImplicitSpecialMember(
+ RD, CSM, MD, CSM == CXXDefaultConstructor ? false : SMI.ConstArg,
+ Diagnose);
}
return false;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D51809.164491.patch
Type: text/x-patch
Size: 1040 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180907/2efcf1a8/attachment.bin>
More information about the cfe-commits
mailing list