[PATCH] D148914: [Sema][NFC] add check before using `BuildExpressionFromIntegralTemplateArgument`
Congcong Cai via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Apr 21 03:15:41 PDT 2023
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 <class F1> int foo(F1 X);
template <int A1> struct A {
template <class F1> 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(),
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D148914.515668.patch
Type: text/x-patch
Size: 689 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230421/e68bed6f/attachment.bin>
More information about the cfe-commits
mailing list