Don't diagnose a redeclaration of a deduction guide if the prior

declaration is not visible.

In passing, add a test for a similar case of conflicting redeclarations
of internal-linkage structured bindings. (This case already works).
This commit is contained in:
Richard Smith 2020-06-12 10:27:48 -07:00
parent a0226f9bff
commit c32d261e27
8 changed files with 30 additions and 2 deletions

View File

@ -678,7 +678,7 @@ bool Sema::MergeCXXFunctionDecl(FunctionDecl *New, FunctionDecl *Old,
// for the same class template shall not have equivalent
// parameter-declaration-clauses.
if (isa<CXXDeductionGuideDecl>(New) &&
!New->isFunctionTemplateSpecialization()) {
!New->isFunctionTemplateSpecialization() && isVisible(Old)) {
Diag(New->getLocation(), diag::err_deduction_guide_redeclared);
Diag(Old->getLocation(), diag::note_previous_declaration);
}

View File

@ -1 +1,4 @@
module Decls { header "decls.h" }
module Decls {
header "decls.h"
explicit module Unimported { header "unimported.h" }
}

View File

@ -0,0 +1,2 @@
template<typename T> struct DeductionGuide {};
DeductionGuide() -> DeductionGuide<int>;

View File

View File

@ -0,0 +1,4 @@
module Decls {
header "decls.h"
explicit module Unimported { header "unimported.h" }
}

View File

@ -0,0 +1,4 @@
namespace StructuredBinding {
struct Q { int p, q; };
static auto [a, b] = Q();
}

View File

@ -9,3 +9,7 @@ struct MergeExceptionSpec {
#include "decls.h"
MergeExceptionSpec mergeExceptionSpec2;
template<typename T> struct DeductionGuide {};
DeductionGuide() -> DeductionGuide<int>;
DeductionGuide a;

View File

@ -0,0 +1,11 @@
// RUN: rm -rf %t
// RUN: %clang_cc1 -x c++ -std=c++20 -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -I %S/Inputs/cxx20 %s -verify -fno-modules-error-recovery
// expected-no-diagnostics
#include "decls.h"
namespace StructuredBinding {
struct R { int x, y; };
static auto [a, b] = R();
}