HerrCai0907 created this revision.
Herald added a project: All.
HerrCai0907 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
This patch wants to avoid Sema crash for inline friend decl like
template int foo(F1 X);
template struct A {
template friend int foo(F1 X) { return A1; }
};
template struct A<1>;
int a = foo(1.0);
But this case is still not fixed
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D148914
Files:
clang/lib/Sema/SemaTemplateInstantiate.cpp
Index: clang/lib/Sema/SemaTemplateInstantiate.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -1849,7 +1849,7 @@
assert(!paramType->isDependentType() && "param type still dependent");
result = SemaRef.BuildExpressionFromDeclTemplateArgument(arg, paramType,
loc);
refParam = paramType->isReferenceType();
- } else {
+ } else if (arg.getKind() == TemplateArgument::Integral) {
result = SemaRef.BuildExpressionFromIntegralTemplateArgument(arg, loc);
assert(result.isInvalid() ||
SemaRef.Context.hasSameType(result.get()->getType(),
Index: clang/lib/Sema/SemaTemplateInstantiate.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -1849,7 +1849,7 @@
assert(!paramType->isDependentType() && "param type still dependent");
result = SemaRef.BuildExpressionFromDeclTemplateArgument(arg, paramType, loc);
refParam = paramType->isReferenceType();
- } else {
+ } else if (arg.getKind() == TemplateArgument::Integral) {
result = SemaRef.BuildExpressionFromIntegralTemplateArgument(arg, loc);
assert(result.isInvalid() ||
SemaRef.Context.hasSameType(result.get()->getType(),
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits