[Cmake-commits] [cmake-commits] king committed cmForEachCommand.cxx 1.28 1.29 cmForEachCommand.h 1.20 1.21 cmFunctionBlocker.h 1.12 1.13 cmFunctionCommand.cxx 1.7 1.8 cmFunctionCommand.h 1.3 1.4 cmIfCommand.cxx 1.92 1.93 cmIfCommand.h 1.51 1.52 cmMacroCommand.cxx 1.37 1.38 cmMacroCommand.h 1.16 1.17 cmMakefile.cxx 1.494 1.495 cmMakefile.h 1.244 1.245 cmWhileCommand.cxx 1.14 1.15 cmWhileCommand.h 1.10 1.11

cmake-commits at cmake.org cmake-commits at cmake.org
Wed Jan 21 09:48:23 EST 2009


Update of /cvsroot/CMake/CMake/Source
In directory public:/mounts/ram/cvs-serv8359/Source

Modified Files:
	cmForEachCommand.cxx cmForEachCommand.h cmFunctionBlocker.h 
	cmFunctionCommand.cxx cmFunctionCommand.h cmIfCommand.cxx 
	cmIfCommand.h cmMacroCommand.cxx cmMacroCommand.h 
	cmMakefile.cxx cmMakefile.h cmWhileCommand.cxx 
	cmWhileCommand.h 
Log Message:
ENH: Better error message for unclosed blocks

This centralizes construction of the error message for an unclosed
logical block (if, foreach, etc.).  We record the line at which each
block is opened so it can be reported in the error message.


Index: cmFunctionCommand.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmFunctionCommand.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -C 2 -d -r1.3 -r1.4
*** cmFunctionCommand.h	23 Jan 2008 15:27:59 -0000	1.3
--- cmFunctionCommand.h	21 Jan 2009 14:48:20 -0000	1.4
***************
*** 35,39 ****
                                   cmExecutionStatus &);
    virtual bool ShouldRemove(const cmListFileFunction&, cmMakefile &mf);
-   virtual void ScopeEnded(cmMakefile &mf);
    
    std::vector<std::string> Args;
--- 35,38 ----

Index: cmMacroCommand.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMacroCommand.h,v
retrieving revision 1.16
retrieving revision 1.17
diff -C 2 -d -r1.16 -r1.17
*** cmMacroCommand.h	23 Jan 2008 15:27:59 -0000	1.16
--- cmMacroCommand.h	21 Jan 2009 14:48:20 -0000	1.17
***************
*** 35,39 ****
                                   cmExecutionStatus &);
    virtual bool ShouldRemove(const cmListFileFunction&, cmMakefile &mf);
-   virtual void ScopeEnded(cmMakefile &mf);
    
    std::vector<std::string> Args;
--- 35,38 ----

Index: cmIfCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmIfCommand.cxx,v
retrieving revision 1.92
retrieving revision 1.93
diff -C 2 -d -r1.92 -r1.93
*** cmIfCommand.cxx	20 Jan 2009 19:36:18 -0000	1.92
--- cmIfCommand.cxx	21 Jan 2009 14:48:20 -0000	1.93
***************
*** 159,180 ****
  
  //=========================================================================
- void cmIfFunctionBlocker::ScopeEnded(cmMakefile &mf)
- {
-   std::string errmsg = "The end of a CMakeLists file was reached with an "
-     "IF statement that was not closed properly.\nWithin the directory: ";
-   errmsg += mf.GetCurrentDirectory();
-   errmsg += "\nThe arguments are: ";
-   for(std::vector<cmListFileArgument>::const_iterator j = this->Args.begin();
-       j != this->Args.end(); ++j)
-     {   
-     errmsg += (j->Quoted?"\"":"");
-     errmsg += j->Value;
-     errmsg += (j->Quoted?"\"":"");
-     errmsg += " ";
-     }
-   cmSystemTools::Message(errmsg.c_str(), "Warning");
- }
- 
- //=========================================================================
  bool cmIfCommand
  ::InvokeInitialPass(const std::vector<cmListFileArgument>& args, 
--- 159,162 ----

Index: cmIfCommand.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmIfCommand.h,v
retrieving revision 1.51
retrieving revision 1.52
diff -C 2 -d -r1.51 -r1.52
*** cmIfCommand.h	20 Jan 2009 19:36:18 -0000	1.51
--- cmIfCommand.h	21 Jan 2009 14:48:20 -0000	1.52
***************
*** 37,41 ****
    virtual bool ShouldRemove(const cmListFileFunction& lff,
                              cmMakefile &mf);
-   virtual void ScopeEnded(cmMakefile &mf);
    
    std::vector<cmListFileArgument> Args;
--- 37,40 ----

Index: cmWhileCommand.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmWhileCommand.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -C 2 -d -r1.10 -r1.11
*** cmWhileCommand.h	20 Jan 2009 19:36:18 -0000	1.10
--- cmWhileCommand.h	21 Jan 2009 14:48:20 -0000	1.11
***************
*** 36,40 ****
                                   cmExecutionStatus &);
    virtual bool ShouldRemove(const cmListFileFunction& lff, cmMakefile &mf);
-   virtual void ScopeEnded(cmMakefile &mf);
    
    std::vector<cmListFileArgument> Args;
--- 36,39 ----

Index: cmWhileCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmWhileCommand.cxx,v
retrieving revision 1.14
retrieving revision 1.15
diff -C 2 -d -r1.14 -r1.15
*** cmWhileCommand.cxx	20 Jan 2009 19:36:18 -0000	1.14
--- cmWhileCommand.cxx	21 Jan 2009 14:48:20 -0000	1.15
***************
*** 98,110 ****
  }
  
- void cmWhileFunctionBlocker::
- ScopeEnded(cmMakefile &mf) 
- {
-   cmSystemTools::Error(
-     "The end of a CMakeLists file was reached with a WHILE statement that "
-     "was not closed properly. Within the directory: ", 
-     mf.GetCurrentDirectory());
- }
- 
  bool cmWhileCommand
  ::InvokeInitialPass(const std::vector<cmListFileArgument>& args, 
--- 98,101 ----

Index: cmMacroCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMacroCommand.cxx,v
retrieving revision 1.37
retrieving revision 1.38
diff -C 2 -d -r1.37 -r1.38
*** cmMacroCommand.cxx	24 Sep 2008 12:51:26 -0000	1.37
--- cmMacroCommand.cxx	21 Jan 2009 14:48:20 -0000	1.38
***************
*** 303,317 ****
  }
  
- void cmMacroFunctionBlocker::
- ScopeEnded(cmMakefile &mf)
- {
-   // macros should end with an EndMacro
-   cmSystemTools::Error(
-     "The end of a CMakeLists file was reached with a MACRO statement that "
-     "was not closed properly. Within the directory: ",
-     mf.GetCurrentDirectory(), " with macro ",
-     this->Args[0].c_str());
- }
- 
  bool cmMacroCommand::InitialPass(std::vector<std::string> const& args,
                                   cmExecutionStatus &)
--- 303,306 ----

Index: cmMakefile.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMakefile.h,v
retrieving revision 1.244
retrieving revision 1.245
diff -C 2 -d -r1.244 -r1.245
*** cmMakefile.h	21 Jan 2009 14:48:00 -0000	1.244
--- cmMakefile.h	21 Jan 2009 14:48:20 -0000	1.245
***************
*** 89,94 ****
     * Add a function blocker to this makefile
     */
!   void AddFunctionBlocker(cmFunctionBlocker *fb)
!     { this->FunctionBlockers.push_back(fb);}
  
    /**
--- 89,93 ----
     * Add a function blocker to this makefile
     */
!   void AddFunctionBlocker(cmFunctionBlocker* fb);
  
    /**

Index: cmFunctionCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmFunctionCommand.cxx,v
retrieving revision 1.7
retrieving revision 1.8
diff -C 2 -d -r1.7 -r1.8
*** cmFunctionCommand.cxx	14 Jan 2009 20:14:06 -0000	1.7
--- cmFunctionCommand.cxx	21 Jan 2009 14:48:17 -0000	1.8
***************
*** 259,273 ****
  }
  
- void cmFunctionFunctionBlocker::
- ScopeEnded(cmMakefile &mf)
- {
-   // functions should end with an EndFunction
-   cmSystemTools::Error(
-     "The end of a CMakeLists file was reached with a FUNCTION statement that "
-     "was not closed properly. Within the directory: ",
-     mf.GetCurrentDirectory(), " with function ",
-     this->Args[0].c_str());
- }
- 
  bool cmFunctionCommand
  ::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
--- 259,262 ----

Index: cmForEachCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmForEachCommand.cxx,v
retrieving revision 1.28
retrieving revision 1.29
diff -C 2 -d -r1.28 -r1.29
*** cmForEachCommand.cxx	20 Jan 2009 19:36:18 -0000	1.28
--- cmForEachCommand.cxx	21 Jan 2009 14:48:16 -0000	1.29
***************
*** 108,120 ****
  }
  
- void cmForEachFunctionBlocker::
- ScopeEnded(cmMakefile &mf) 
- {
-   cmSystemTools::Error("The end of a CMakeLists file was reached with a "
-                        "FOREACH statement that was not closed properly. "
-                        "Within the directory: ", 
-                        mf.GetCurrentDirectory());
- }
- 
  bool cmForEachCommand
  ::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
--- 108,111 ----

Index: cmFunctionBlocker.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmFunctionBlocker.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -C 2 -d -r1.12 -r1.13
*** cmFunctionBlocker.h	23 Jan 2008 15:27:59 -0000	1.12
--- cmFunctionBlocker.h	21 Jan 2009 14:48:16 -0000	1.13
***************
*** 20,23 ****
--- 20,24 ----
  #include "cmStandardIncludes.h"
  #include "cmExecutionStatus.h"
+ #include "cmListFileCache.h"
  class cmMakefile;
  
***************
*** 44,55 ****
                              cmMakefile&) {return false;}
  
-   /**
-    * When the end of a CMakeList file is reached this method is called.  It
-    * is not called on the end of an INCLUDE cmake file, just at the end of a
-    * regular CMakeList file 
-    */
-   virtual void ScopeEnded(cmMakefile&) {}
- 
    virtual ~cmFunctionBlocker() {}
  };
  
--- 45,57 ----
                              cmMakefile&) {return false;}
  
    virtual ~cmFunctionBlocker() {}
+ 
+   /** Set/Get the context in which this blocker is created.  */
+   void SetStartingContext(cmListFileContext const& lfc)
+     { this->StartingContext = lfc; }
+   cmListFileContext const& GetStartingContext()
+     { return this->StartingContext; }
+ private:
+   cmListFileContext StartingContext;
  };
  

Index: cmForEachCommand.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmForEachCommand.h,v
retrieving revision 1.20
retrieving revision 1.21
diff -C 2 -d -r1.20 -r1.21
*** cmForEachCommand.h	20 Jan 2009 19:36:18 -0000	1.20
--- cmForEachCommand.h	21 Jan 2009 14:48:16 -0000	1.21
***************
*** 36,40 ****
                                   cmExecutionStatus &);
    virtual bool ShouldRemove(const cmListFileFunction& lff, cmMakefile &mf);
-   virtual void ScopeEnded(cmMakefile &mf);
    
    std::vector<std::string> Args;
--- 36,39 ----

Index: cmMakefile.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMakefile.cxx,v
retrieving revision 1.494
retrieving revision 1.495
diff -C 2 -d -r1.494 -r1.495
*** cmMakefile.cxx	21 Jan 2009 14:48:00 -0000	1.494
--- cmMakefile.cxx	21 Jan 2009 14:48:20 -0000	1.495
***************
*** 2366,2370 ****
      if(reportError)
        {
!       fb->ScopeEnded(*this);
        }
      }
--- 2366,2377 ----
      if(reportError)
        {
!       // Report the context in which the unclosed block was opened.
!       cmListFileContext const& lfc = fb->GetStartingContext();
!       cmOStringStream e;
!       e << "A logical block opening on the line\n"
!         << "  " << lfc << "\n"
!         << "is not closed.";
!       this->IssueMessage(cmake::FATAL_ERROR, e.str());
!       reportError = false;
        }
      }
***************
*** 2403,2406 ****
--- 2410,2425 ----
  }
  
+ //----------------------------------------------------------------------------
+ void cmMakefile::AddFunctionBlocker(cmFunctionBlocker* fb)
+ {
+   if(!this->CallStack.empty())
+     {
+     // Record the context in which the blocker is created.
+     fb->SetStartingContext(*(this->CallStack.back().Context));
+     }
+ 
+   this->FunctionBlockers.push_back(fb);
+ }
+ 
  cmsys::auto_ptr<cmFunctionBlocker>
  cmMakefile::RemoveFunctionBlocker(const cmListFileFunction& lff)



More information about the Cmake-commits mailing list