From 95e8d658fbea5b53c5e77c48f883fe6c9f7f620f Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 24 Feb 2009 22:46:58 +0000 Subject: [PATCH] Make CheckSingleInitializer a static function in SemaInit.cpp git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65397 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/Sema.h | 2 -- lib/Sema/SemaInit.cpp | 26 +++++++++++++------------- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/lib/Sema/Sema.h b/lib/Sema/Sema.h index 72f220a782..09cf6813ca 100644 --- a/lib/Sema/Sema.h +++ b/lib/Sema/Sema.h @@ -1889,8 +1889,6 @@ public: SourceLocation InitLoc,DeclarationName InitEntity, bool DirectInit); bool CheckInitList(InitListExpr *&InitList, QualType &DeclType); - bool CheckSingleInitializer(Expr *&simpleInit, QualType declType, - bool DirectInit); bool CheckForConstantInitializer(Expr *e, QualType t); bool CheckArithmeticConstantExpression(const Expr* e); bool CheckAddressConstantExpression(const Expr* e); diff --git a/lib/Sema/SemaInit.cpp b/lib/Sema/SemaInit.cpp index 8f3a210efc..cb2fdd2736 100644 --- a/lib/Sema/SemaInit.cpp +++ b/lib/Sema/SemaInit.cpp @@ -35,25 +35,25 @@ static StringLiteral *IsStringInit(Expr *Init, QualType DeclType, return 0; } -bool Sema::CheckSingleInitializer(Expr *&Init, QualType DeclType, - bool DirectInit) { +static bool CheckSingleInitializer(Expr *&Init, QualType DeclType, + bool DirectInit, Sema &S) { // Get the type before calling CheckSingleAssignmentConstraints(), since // it can promote the expression. QualType InitType = Init->getType(); - if (getLangOptions().CPlusPlus) { + if (S.getLangOptions().CPlusPlus) { // FIXME: I dislike this error message. A lot. - if (PerformImplicitConversion(Init, DeclType, "initializing", DirectInit)) - return Diag(Init->getSourceRange().getBegin(), - diag::err_typecheck_convert_incompatible) - << DeclType << Init->getType() << "initializing" - << Init->getSourceRange(); - + if (S.PerformImplicitConversion(Init, DeclType, "initializing", DirectInit)) + return S.Diag(Init->getSourceRange().getBegin(), + diag::err_typecheck_convert_incompatible) + << DeclType << Init->getType() << "initializing" + << Init->getSourceRange(); return false; } - AssignConvertType ConvTy = CheckSingleAssignmentConstraints(DeclType, Init); - return DiagnoseAssignmentResult(ConvTy, Init->getLocStart(), DeclType, + Sema::AssignConvertType ConvTy = + S.CheckSingleAssignmentConstraints(DeclType, Init); + return S.DiagnoseAssignmentResult(ConvTy, Init->getLocStart(), DeclType, InitType, Init, "initializing"); } @@ -163,7 +163,7 @@ bool Sema::CheckInitializerTypes(Expr *&Init, QualType &DeclType, return Diag(Init->getLocStart(), diag::err_array_init_list_required) << Init->getSourceRange(); - return CheckSingleInitializer(Init, DeclType, DirectInit); + return CheckSingleInitializer(Init, DeclType, DirectInit, *this); } bool hadError = CheckInitList(InitList, DeclType); @@ -676,7 +676,7 @@ void InitListChecker::CheckScalarType(InitListExpr *IList, QualType DeclType, } Expr *savExpr = expr; // Might be promoted by CheckSingleInitializer. - if (SemaRef->CheckSingleInitializer(expr, DeclType, false)) + if (CheckSingleInitializer(expr, DeclType, false, *SemaRef)) hadError = true; // types weren't compatible. else if (savExpr != expr) { // The type was promoted, update initializer list. -- 2.40.0