Fix comparison of Structural Values

Fixes a regression from #78041 as reported in the review.  The original
patch failed to compare the canonical type, which this adds.  A slightly
modified test of the original report is added.

(cherry picked from commit e3ee3762304aa81e4a240500844bfdd003401b36)
This commit is contained in:
erichkeane 2024-01-24 12:07:22 -08:00 committed by Tom Stellard
parent 2cf04c020f
commit 16bfe1e89f
2 changed files with 20 additions and 1 deletions

View File

@ -450,7 +450,8 @@ bool TemplateArgument::structurallyEquals(const TemplateArgument &Other) const {
getAsIntegral() == Other.getAsIntegral();
case StructuralValue: {
if (getStructuralValueType() != Other.getStructuralValueType())
if (getStructuralValueType().getCanonicalType() !=
Other.getStructuralValueType().getCanonicalType())
return false;
llvm::FoldingSetNodeID A, B;

View File

@ -336,3 +336,21 @@ template<int ...Ns> void bar(B b) {
(b.operator Tbar<Ns>(), ...);
}
}
namespace ReportedRegression1 {
const char kt[] = "dummy";
template <class T, const char id[]>
class SomeTempl { };
template <const char id[]>
class SomeTempl<int, id> {
public:
int exit_code() const { return 0; }
};
int use() {
SomeTempl<int, kt> dummy;
return dummy.exit_code();
}
}