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(),
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