]> granicus.if.org Git - clang/commitdiff
Make CheckSingleInitializer a static function in SemaInit.cpp
authorChris Lattner <sabre@nondot.org>
Tue, 24 Feb 2009 22:46:58 +0000 (22:46 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 24 Feb 2009 22:46:58 +0000 (22:46 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65397 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/Sema.h
lib/Sema/SemaInit.cpp

index 72f220a78245bbefba77b40dfbaeafe40b86bea1..09cf6813cae0f71e2babdf2b52aaf4f015ec996f 100644 (file)
@@ -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);
index 8f3a210efccc428ea944241633212df053ebe6d2..cb2fdd2736cbacc3767b780d0978ed0e3e93e414 100644 (file)
@@ -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.