diff --git a/clang/include/clang/AST/DeclTemplate.h b/clang/include/clang/AST/DeclTemplate.h --- a/clang/include/clang/AST/DeclTemplate.h +++ b/clang/include/clang/AST/DeclTemplate.h @@ -3287,8 +3287,12 @@ return isa(getTemplateParameters()->getParam(0)); } - ConceptDecl *getCanonicalDecl() override { return getFirstDecl(); } - const ConceptDecl *getCanonicalDecl() const { return getFirstDecl(); } + ConceptDecl *getCanonicalDecl() override { + return cast(getPrimaryMergedDecl(this)); + } + const ConceptDecl *getCanonicalDecl() const { + return const_cast(this)->getCanonicalDecl(); + } // Implement isa/cast/dyncast/etc. static bool classof(const Decl *D) { return classofKind(D->getKind()); } diff --git a/clang/test/Modules/merge-concepts.cpp b/clang/test/Modules/merge-concepts.cpp --- a/clang/test/Modules/merge-concepts.cpp +++ b/clang/test/Modules/merge-concepts.cpp @@ -47,7 +47,10 @@ #define SAME_AS_H template -concept same_as = __is_same(T, U); +concept same_as_impl = __is_same(T, U); + +template +concept same_as = same_as_impl && same_as_impl; #endif // SAME_AS_H @@ -55,11 +58,11 @@ #ifndef FORMAT_H #define FORMAT_H -#include "concepts.h" #include "same_as.h" +#include "concepts.h" template void foo() requires same_as {} -#endif // FORMAT_H \ No newline at end of file +#endif // FORMAT_H