diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index a77f7a460242bb..f1ade752e2fe46 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -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(New) && - !New->isFunctionTemplateSpecialization()) { + !New->isFunctionTemplateSpecialization() && isVisible(Old)) { Diag(New->getLocation(), diag::err_deduction_guide_redeclared); Diag(Old->getLocation(), diag::note_previous_declaration); } diff --git a/clang/test/Modules/Inputs/cxx17/module.modulemap b/clang/test/Modules/Inputs/cxx17/module.modulemap index 2339e49e03bd9c..c80e6e7b13eb26 100644 --- a/clang/test/Modules/Inputs/cxx17/module.modulemap +++ b/clang/test/Modules/Inputs/cxx17/module.modulemap @@ -1 +1,4 @@ -module Decls { header "decls.h" } +module Decls { + header "decls.h" + explicit module Unimported { header "unimported.h" } +} diff --git a/clang/test/Modules/Inputs/cxx17/unimported.h b/clang/test/Modules/Inputs/cxx17/unimported.h new file mode 100644 index 00000000000000..97c75e635d8371 --- /dev/null +++ b/clang/test/Modules/Inputs/cxx17/unimported.h @@ -0,0 +1,2 @@ +template struct DeductionGuide {}; +DeductionGuide() -> DeductionGuide; diff --git a/clang/test/Modules/Inputs/cxx20/decls.h b/clang/test/Modules/Inputs/cxx20/decls.h new file mode 100644 index 00000000000000..e69de29bb2d1d6 diff --git a/clang/test/Modules/Inputs/cxx20/module.modulemap b/clang/test/Modules/Inputs/cxx20/module.modulemap new file mode 100644 index 00000000000000..c80e6e7b13eb26 --- /dev/null +++ b/clang/test/Modules/Inputs/cxx20/module.modulemap @@ -0,0 +1,4 @@ +module Decls { + header "decls.h" + explicit module Unimported { header "unimported.h" } +} diff --git a/clang/test/Modules/Inputs/cxx20/unimported.h b/clang/test/Modules/Inputs/cxx20/unimported.h new file mode 100644 index 00000000000000..226b087c0848c1 --- /dev/null +++ b/clang/test/Modules/Inputs/cxx20/unimported.h @@ -0,0 +1,4 @@ +namespace StructuredBinding { + struct Q { int p, q; }; + static auto [a, b] = Q(); +} diff --git a/clang/test/Modules/cxx17.cpp b/clang/test/Modules/cxx17.cpp index 1efb490828db5b..87039ef7665600 100644 --- a/clang/test/Modules/cxx17.cpp +++ b/clang/test/Modules/cxx17.cpp @@ -9,3 +9,7 @@ struct MergeExceptionSpec { #include "decls.h" MergeExceptionSpec mergeExceptionSpec2; + +template struct DeductionGuide {}; +DeductionGuide() -> DeductionGuide; +DeductionGuide a; diff --git a/clang/test/Modules/cxx20.cpp b/clang/test/Modules/cxx20.cpp new file mode 100644 index 00000000000000..e85bc9ad8a8fc0 --- /dev/null +++ b/clang/test/Modules/cxx20.cpp @@ -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(); +}