[PATCH] D57540: [C++17] Don't crash while diagnosing different access specifier of a deduction guide.
Nicolas Lesser via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Jan 31 13:20:21 PST 2019
Rakete1111 created this revision.
Rakete1111 added a reviewer: rsmith.
This fixes PR40552 by not showing the diagnostic that complains about different access specifiers, since the template does not have one.
Repository:
rC Clang
https://reviews.llvm.org/D57540
Files:
lib/Sema/SemaDeclCXX.cpp
test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
Index: test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
===================================================================
--- test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
+++ test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
@@ -353,6 +353,13 @@
template<typename T> Protected(T) -> Protected<T>; // expected-error {{different access}}
template<typename T> Private(T) -> Private<T>; // expected-error {{different access}}
};
+
+ // PR40552
+ template <typename> struct Typo {}; // expected-note{{template is declared here}}
+ struct Type {
+ Typo(); // expected-error{{deduction guide must be declared in the same scope}}
+ // expected-error at -1{{deduction guide declaration without trailing return type}}
+ };
}
namespace rdar41903969 {
Index: lib/Sema/SemaDeclCXX.cpp
===================================================================
--- lib/Sema/SemaDeclCXX.cpp
+++ lib/Sema/SemaDeclCXX.cpp
@@ -3175,7 +3175,7 @@
// declared] with the same access [as the template].
if (auto *DG = dyn_cast<CXXDeductionGuideDecl>(NonTemplateMember)) {
auto *TD = DG->getDeducedTemplate();
- if (AS != TD->getAccess()) {
+ if (AS != TD->getAccess() && TD->getAccess() != AS_none) {
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: D57540.184589.patch
Type: text/x-patch
Size: 1437 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190131/dc2a9c9a/attachment.bin>
More information about the cfe-commits
mailing list