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@-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();


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@-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();
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
  • [PATCH] D57540: [... Nicolas Lesser via Phabricator via cfe-commits

Reply via email to