================ @@ -4887,9 +4887,18 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state, cast<AutoType>(T)->getKeyword() != AutoTypeKeyword::Auto || cast<AutoType>(T)->isConstrained())) { - S.Diag(D.getDeclSpec().getTypeSpecTypeLoc(), - diag::err_trailing_return_without_auto) - << T << D.getDeclSpec().getSourceRange(); + SourceLocation Loc = D.getDeclSpec().getTypeSpecTypeLoc(); + SourceRange SR = D.getDeclSpec().getSourceRange(); + if (Loc.isInvalid()) { + TypeSourceInfo *TSI = nullptr; + S.GetTypeFromParser(FTI.getTrailingReturnType(), &TSI); + if (TSI) { + TypeLoc TSILoc = TSI->getTypeLoc(); + Loc = TSILoc.getBeginLoc(); + SR = TSILoc.getSourceRange(); + } + } + S.Diag(Loc, diag::err_trailing_return_without_auto) << T << SR; ---------------- a-tarasyuk wrote:
@Fznamznon thanks for the feedback! I think it could use the full range of the string, though I’m unsure if that’s acceptable... ``` template <typename T> struct B { // CHECK-NEXT: {{^}} template <class U> B(U) -> B<int>; // CHECK-NEXT: {{^}} ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ template <class U> B(U) -> B<int>; }; ``` https://github.com/llvm/llvm-project/pull/115786 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits