]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[4203] Added new fatal class method for yy_fatal_error fix
authorFrancis Dupont <fdupont@isc.org>
Wed, 18 Nov 2015 23:52:57 +0000 (00:52 +0100)
committerFrancis Dupont <fdupont@isc.org>
Wed, 18 Nov 2015 23:52:57 +0000 (00:52 +0100)
src/lib/eval/eval_context.cc
src/lib/eval/eval_context.h
src/lib/eval/lexer.ll

index 7dc46fc4ccbf6913d82e41eb90369e9e134859d9..99cc4e085c73b3ef9cc0614818aec85fca4f2ec3 100644 (file)
@@ -50,3 +50,9 @@ EvalContext::error (const std::string& what)
 {
     isc_throw(EvalParseError, what);
 }
+
+void
+EvalContext::fatal (const std::string& what)
+{
+    isc_throw(Unexpected, what);
+}
index 6b28e2b16147946c7632f580162dc9c2690a99fe..e1721baf199df1a66a762b6f75f58dc29c6e3d4f 100644 (file)
@@ -81,6 +81,11 @@ public:
     /// cases when the EvalParser is not able to handle the packet.
     void error(const std::string& what);
 
+    /// @brief Fatal error handler
+    ///
+    /// This is for should not happen but fatal errors
+    static void fatal(const std::string& what);
+
  private:
     /// @brief Flag determining scanner debugging.
     bool trace_scanning_;
index 71d5eaab031912f8219317c294a02bf35abc53d8..c534084d6cc8ae8d123bdf72f105556c62f496c8 100644 (file)
@@ -31,6 +31,9 @@
 // The location of the current token. The lexer will keep updating it. This
 // variable will be useful for logging errors.
 static isc::eval::location loc;
+
+// To avoid the call to exit... oops!
+#define YY_FATAL_ERROR(msg) isc::eval::EvalContext::fatal(msg)
 %}
 
 /* noyywrap disables automatic rewinding for the next file to parse. Since we
@@ -144,8 +147,8 @@ EvalContext::scanStringBegin()
     YY_BUFFER_STATE buffer;
     buffer = yy_scan_bytes(string_.c_str(), string_.size());
     if (!buffer) {
-        error("cannot scan string");
-       // error throws an exception so this can't be reached
+        fatal("cannot scan string");
+       // fatal() throws an exception so this can't be reached
     }
 }
 
@@ -154,3 +157,10 @@ EvalContext::scanStringEnd()
 {
     yy_delete_buffer(YY_CURRENT_BUFFER);
 }
+
+namespace {
+/// To avoid unused function error
+class Dummy {
+    void dummy() { yy_fatal_error("Fix me: how to disable its definition?"); }
+};
+}