[PATCH] D58111: [Sema] Fix a crash in access checking for deduction guides
Phabricator via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Feb 12 06:21:25 PST 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rC353840: [Sema] Fix a crash in access checking for deduction guides (authored by ibiryukov, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D58111?vs=186447&id=186450#toc
Repository:
rC Clang
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D58111/new/
https://reviews.llvm.org/D58111
Files:
lib/Sema/SemaDeclCXX.cpp
test/Sema/crash-deduction-guide-access.cpp
Index: test/Sema/crash-deduction-guide-access.cpp
===================================================================
--- test/Sema/crash-deduction-guide-access.cpp
+++ test/Sema/crash-deduction-guide-access.cpp
@@ -0,0 +1,11 @@
+// RUN: not %clang_cc1 -x c++ -std=c++17 -fsyntax-only %s
+template <typename U>
+class Imp {
+ template <typename F>
+ explicit Imp(F f);
+};
+
+template <typename T>
+class Cls {
+ explicit Imp() : f() {}
+};
Index: lib/Sema/SemaDeclCXX.cpp
===================================================================
--- lib/Sema/SemaDeclCXX.cpp
+++ lib/Sema/SemaDeclCXX.cpp
@@ -3175,7 +3175,11 @@
// declared] with the same access [as the template].
if (auto *DG = dyn_cast<CXXDeductionGuideDecl>(NonTemplateMember)) {
auto *TD = DG->getDeducedTemplate();
- if (AS != TD->getAccess()) {
+ // Access specifiers are only meaningful if both the template and the
+ // deduction guide are from the same scope.
+ if (AS != TD->getAccess() &&
+ TD->getDeclContext()->getRedeclContext()->Equals(
+ DG->getDeclContext()->getRedeclContext())) {
Diag(DG->getBeginLoc(), diag::err_deduction_guide_wrong_access);
Diag(TD->getBeginLoc(), diag::note_deduction_guide_template_access)
<< TD->getAccess();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D58111.186450.patch
Type: text/x-patch
Size: 1308 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190212/d4bed3fe/attachment-0001.bin>
More information about the cfe-commits
mailing list