diff options
Diffstat (limited to 'lib/Sema/SemaDecl.cpp')
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index df077fd709..2b42fb60fb 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -3171,7 +3171,7 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC, SC = SC_Static; break; } - case DeclSpec::SCS_private_extern: SC = SC_PrivateExtern;break; + case DeclSpec::SCS_private_extern: SC = SC_PrivateExtern; break; } if (D.getDeclSpec().isThreadSpecified()) @@ -3976,8 +3976,14 @@ void Sema::CheckMain(FunctionDecl* FD) { const FunctionType* FT = T->getAs<FunctionType>(); if (!Context.hasSameUnqualifiedType(FT->getResultType(), Context.IntTy)) { - // TODO: add a replacement fixit to turn the return type into 'int'. - Diag(FD->getTypeSpecStartLoc(), diag::err_main_returns_nonint); + TypeSourceInfo *TSI = FD->getTypeSourceInfo(); + TypeLoc TL = TSI->getTypeLoc(); + const SemaDiagnosticBuilder& D = Diag(FD->getTypeSpecStartLoc(), + diag::err_main_returns_nonint); + if (FunctionTypeLoc* PTL = dyn_cast<FunctionTypeLoc>(&TL)) { + D << FixItHint::CreateReplacement(PTL->getResultLoc().getSourceRange(), + "int"); + } FD->setInvalidDecl(true); } |