Skip to content

Commit

Permalink
Fix comparison of Structural Values
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
erichkeane committed Jan 24, 2024
1 parent e6f576b commit e3ee376
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
3 changes: 2 additions & 1 deletion clang/lib/AST/TemplateBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
18 changes: 18 additions & 0 deletions clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}

0 comments on commit e3ee376

Please sign in to comment.