Skip to content

Commit 40b33b3

Browse files
erichkeanetstellar
authored andcommitted
Fix comparison of Structural Values
Fixes a regression from llvm#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 e3ee376)
1 parent e4c0024 commit 40b33b3

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

clang/lib/AST/TemplateBase.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,8 @@ bool TemplateArgument::structurallyEquals(const TemplateArgument &Other) const {
450450
getAsIntegral() == Other.getAsIntegral();
451451

452452
case StructuralValue: {
453-
if (getStructuralValueType() != Other.getStructuralValueType())
453+
if (getStructuralValueType().getCanonicalType() !=
454+
Other.getStructuralValueType().getCanonicalType())
454455
return false;
455456

456457
llvm::FoldingSetNodeID A, B;

clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp

+18
Original file line numberDiff line numberDiff line change
@@ -336,3 +336,21 @@ template<int ...Ns> void bar(B b) {
336336
(b.operator Tbar<Ns>(), ...);
337337
}
338338
}
339+
340+
namespace ReportedRegression1 {
341+
const char kt[] = "dummy";
342+
343+
template <class T, const char id[]>
344+
class SomeTempl { };
345+
346+
template <const char id[]>
347+
class SomeTempl<int, id> {
348+
public:
349+
int exit_code() const { return 0; }
350+
};
351+
352+
int use() {
353+
SomeTempl<int, kt> dummy;
354+
return dummy.exit_code();
355+
}
356+
}

0 commit comments

Comments
 (0)