return isa<TemplateTypeParmDecl>(getTemplateParameters()->getParam(0));
}
- ConceptDecl *getCanonicalDecl() override { return getFirstDecl(); }
- const ConceptDecl *getCanonicalDecl() const { return getFirstDecl(); }
+ ConceptDecl *getCanonicalDecl() override {
+ return cast<ConceptDecl>(getPrimaryMergedDecl(this));
+ }
+ const ConceptDecl *getCanonicalDecl() const {
+ return const_cast<ConceptDecl *>(this)->getCanonicalDecl();
+ }
// Implement isa/cast/dyncast/etc.
static bool classof(const Decl *D) { return classofKind(D->getKind()); }
// Other decls (e.g. namespaces) also have this shortcoming.
return;
}
- Context.setPrimaryMergedDecl(NewDecl, OldConcept);
+ // We unwrap canonical decl late to check for module visibility.
+ Context.setPrimaryMergedDecl(NewDecl, OldConcept->getCanonicalDecl());
}
/// \brief Strips various properties off an implicit instantiation
export *
header "concepts.h"
}
+ module "compare" {
+ export *
+ header "compare.h"
+ }
module "format" {
export *
header "format.h"
#define SAME_AS_H
template <class T, class U>
-concept same_as = __is_same(T, U);
+concept same_as_impl = __is_same(T, U);
+template <class T, class U>
+concept same_as = same_as_impl<T, U> && same_as_impl<U, T>;
#endif // SAME_AS_H
+
+//--- compare.h
+#ifndef COMPARE_H
+#define COMPARE_H
+
+#include "same_as.h"
+#include "concepts.h"
+
+template <class T> void foo()
+ requires same_as<T, int>
+{}
+#endif // COMPARE_H
+
//--- format.h
#ifndef FORMAT_H
#define FORMAT_H
-#include "concepts.h"
#include "same_as.h"
+#include "concepts.h"
-template <class T> void foo()
+template <class T> void bar()
requires same_as<T, int>
{}
-#endif // FORMAT_H
\ No newline at end of file
+#endif // FORMAT_H