changeset 20957:9db35d2042be

maint: eliminate special cases of statements after error. * daspk.cc: Eliminate DASPK_ABORT, DASPK_ABORT1, DASPK_ABORT2 macros. * dasrt.cc: Eliminate DASRT_ABORT, DASRT_ABORT1, DASRT_ABORT2 macros. * dassl.cc: Eliminate DASSL_ABORT, DASSL_ABORT1, DASSL_ABORT2 macros. libinterp/corefcn/graphics.cc (Fdrawnow): Reverse order and call gh_manager::unlock() before call to error(). * variables.cc (Fmlock): Adjust indentation. * __glpk__.cc (glpk): Add FIXME note about unreachable code. * __init_fltk__.cc (F__fltk_check__, F__init_fltk__): Place return statement within #ifdef HAVE_FLTK block. * ov-fcn-handle.cc (load_hdf5): eliminate useless statements after error. * ov-java.cc (F__java_exit__): Place return statement within #ifdef HAVE_JAVA block. * octave.cc (octave_process_command_line): Issue warning, which will return, and then call octave_print_terse_usage_and_exit. * lex.ll: Add FIXME notes about unreachable code. * oct-parse.in.yy (source_file): Eliminate useless return after error.
author Rik <rik@octave.org>
date Sun, 20 Dec 2015 15:31:53 -0800
parents 850e3d2533d4
children 249a4659dfa5
files libinterp/corefcn/daspk.cc libinterp/corefcn/dasrt.cc libinterp/corefcn/dassl.cc libinterp/corefcn/graphics.cc libinterp/corefcn/variables.cc libinterp/dldfcn/__glpk__.cc libinterp/dldfcn/__init_fltk__.cc libinterp/octave-value/ov-fcn-handle.cc libinterp/octave-value/ov-java.cc libinterp/octave.cc libinterp/parse-tree/lex.ll libinterp/parse-tree/oct-parse.in.yy
diffstat 12 files changed, 40 insertions(+), 99 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/daspk.cc	Sun Dec 20 13:26:17 2015 -0800
+++ b/libinterp/corefcn/daspk.cc	Sun Dec 20 15:31:53 2015 -0800
@@ -157,25 +157,6 @@
   return retval;
 }
 
-#define DASPK_ABORT() \
-  return retval
-
-#define DASPK_ABORT1(msg) \
-  do \
-    { \
-      error ("daspk: " msg); \
-      DASPK_ABORT (); \
-    } \
-  while (0)
-
-#define DASPK_ABORT2(fmt, arg) \
-  do \
-    { \
-      error ("daspk: " fmt, arg); \
-      DASPK_ABORT (); \
-    } \
-  while (0)
-
 DEFUN (daspk, args, nargout,
        "-*- texinfo -*-\n\
 @deftypefn {} {[@var{x}, @var{xdot}, @var{istate}, @var{msg}] =} daspk (@var{fcn}, @var{x_0}, @var{xdot_0}, @var{t}, @var{t_crit})\n\
@@ -293,7 +274,7 @@
   call_depth++;
 
   if (call_depth > 1)
-    DASPK_ABORT1 ("invalid recursive call");
+    error ("daspk: invalid recursive call");
 
   std::string fcn_name, fname, jac_name, jname;
   daspk_fcn = 0;
@@ -343,7 +324,7 @@
             }
         }
       else
-        DASPK_ABORT1 ("incorrect number of elements in cell array");
+        error ("daspk: incorrect number of elements in cell array");
     }
 
   if (! daspk_fcn && ! f_arg.is_cell ())
@@ -401,7 +382,7 @@
     }
 
   if (! daspk_fcn)
-    DASPK_ABORT ();
+    return retval;
 
   ColumnVector state = args(1).xvector_value ("daspk: initial state X_0 must be a vector");
 
@@ -419,7 +400,7 @@
     }
 
   if (state.numel () != deriv.numel ())
-    DASPK_ABORT1 ("X_0 and XDOT_0 must have the same size");
+    error ("daspk: X_0 and XDOT_0 must have the same size");
 
   double tzero = out_times (0);
 
--- a/libinterp/corefcn/dasrt.cc	Sun Dec 20 13:26:17 2015 -0800
+++ b/libinterp/corefcn/dasrt.cc	Sun Dec 20 15:31:53 2015 -0800
@@ -196,25 +196,6 @@
   return retval;
 }
 
-#define DASRT_ABORT \
-  return retval
-
-#define DASRT_ABORT1(msg) \
-  do \
-    { \
-      error ("dasrt: " msg); \
-      DASRT_ABORT; \
-    } \
-  while (0)
-
-#define DASRT_ABORT2(fmt, arg) \
-  do \
-    { \
-      error ("dasrt: " fmt, arg); \
-      DASRT_ABORT; \
-    } \
-  while (0)
-
 DEFUN (dasrt, args, nargout,
        "-*- texinfo -*-\n\
 @deftypefn  {} {[@var{x}, @var{xdot}, @var{t_out}, @var{istat}, @var{msg}] =} dasrt (@var{fcn}, [], @var{x_0}, @var{xdot_0}, @var{t})\n\
@@ -373,7 +354,7 @@
   call_depth++;
 
   if (call_depth > 1)
-    DASRT_ABORT1 ("invalid recursive call");
+    error ("dasrt: invalid recursive call");
 
   int argp = 0;
   std::string fcn_name, fname, jac_name, jname;
@@ -429,7 +410,7 @@
             }
         }
       else
-        DASRT_ABORT1 ("incorrect number of elements in cell array");
+        error ("dasrt: incorrect number of elements in cell array");
     }
 
   if (! dasrt_f && ! f_arg.is_cell ())
@@ -476,14 +457,13 @@
               break;
 
             default:
-              DASRT_ABORT1
-                ("first arg should be a string or 2-element string array");
+              error ("dasrt: first arg should be a string or 2-element string array");
             }
         }
     }
 
   if (! dasrt_f)
-    DASRT_ABORT;
+    return retval;
 
   DAERTFunc func (dasrt_user_f);
 
@@ -494,7 +474,7 @@
       dasrt_cf = args(1).function_value ();
 
       if (! dasrt_cf)
-        DASRT_ABORT1 ("invalid constraint function G");
+        error ("dasrt: invalid constraint function G");
 
       argp++;
 
@@ -504,7 +484,7 @@
     {
       dasrt_cf = is_valid_function (args(1), "dasrt", true);
       if (! dasrt_cf)
-        DASRT_ABORT1 ("invalid constraint function G");
+        error ("dasrt: invalid constraint function G");
 
       argp++;
 
--- a/libinterp/corefcn/dassl.cc	Sun Dec 20 13:26:17 2015 -0800
+++ b/libinterp/corefcn/dassl.cc	Sun Dec 20 15:31:53 2015 -0800
@@ -157,25 +157,6 @@
   return retval;
 }
 
-#define DASSL_ABORT() \
-  return retval
-
-#define DASSL_ABORT1(msg) \
-  do \
-    { \
-      error ("dassl: " msg); \
-      DASSL_ABORT (); \
-    } \
-  while (0)
-
-#define DASSL_ABORT2(fmt, arg) \
-  do \
-    { \
-      error ("dassl: " fmt, arg); \
-      DASSL_ABORT (); \
-    } \
-  while (0)
-
 DEFUN (dassl, args, nargout,
        "-*- texinfo -*-\n\
 @deftypefn {} {[@var{x}, @var{xdot}, @var{istate}, @var{msg}] =} dassl (@var{fcn}, @var{x_0}, @var{xdot_0}, @var{t}, @var{t_crit})\n\
@@ -294,7 +275,7 @@
   call_depth++;
 
   if (call_depth > 1)
-    DASSL_ABORT1 ("invalid recursive call");
+    error ("dassl: invalid recursive call");
 
   std::string fcn_name, fname, jac_name, jname;
   dassl_fcn = 0;
@@ -344,7 +325,7 @@
             }
         }
       else
-        DASSL_ABORT1 ("incorrect number of elements in cell array");
+        error ("dassl: incorrect number of elements in cell array");
     }
 
   if (! dassl_fcn && ! f_arg.is_cell ())
@@ -402,7 +383,7 @@
     }
 
   if (! dassl_fcn)
-    DASSL_ABORT ();
+    return retval;
 
   ColumnVector state = args(1).xvector_value ("dassl: initial state X_0 must be a vector");
 
@@ -420,7 +401,7 @@
     }
 
   if (state.numel () != deriv.numel ())
-    DASSL_ABORT1 ("X and XDOT_0 must have the same size");
+    error ("dassl: X and XDOT_0 must have the same size");
 
   double tzero = out_times (0);
 
--- a/libinterp/corefcn/graphics.cc	Sun Dec 20 13:26:17 2015 -0800
+++ b/libinterp/corefcn/graphics.cc	Sun Dec 20 15:31:53 2015 -0800
@@ -10843,19 +10843,15 @@
           if (pos_p == std::string::npos &&
               pos_c == std::string::npos)
             {
+              gh_manager::unlock ();
+
               error ("drawnow: empty output ''");
-
-              gh_manager::unlock ();
-
-              return ovl ();
             }
           else if (pos_c == std::string::npos)
             {
+              gh_manager::unlock ();
+
               error ("drawnow: empty pipe '|'");
-
-              gh_manager::unlock ();
-
-              return ovl ();
             }
           else if (pos_p != std::string::npos && pos_p < pos_c)
             {
--- a/libinterp/corefcn/variables.cc	Sun Dec 20 13:26:17 2015 -0800
+++ b/libinterp/corefcn/variables.cc	Sun Dec 20 15:31:53 2015 -0800
@@ -1990,7 +1990,7 @@
   if (! fcn)
     error ("mlock: invalid use outside a function");
 
-    fcn->lock ();
+  fcn->lock ();
 
   return ovl ();
 }
--- a/libinterp/dldfcn/__glpk__.cc	Sun Dec 20 13:26:17 2015 -0800
+++ b/libinterp/dldfcn/__glpk__.cc	Sun Dec 20 15:31:53 2015 -0800
@@ -170,6 +170,8 @@
       static char tmp[] = "outpb.lp";
       if (glp_write_lp (lp, NULL, tmp) != 0)
         {
+          // FIXME: This doesn't work anymore now that error does not return.
+          //        Should longjmp just be deleted?
           error ("__glpk__: unable to write problem");
           longjmp (mark, -1);
         }
--- a/libinterp/dldfcn/__init_fltk__.cc	Sun Dec 20 13:26:17 2015 -0800
+++ b/libinterp/dldfcn/__init_fltk__.cc	Sun Dec 20 15:31:53 2015 -0800
@@ -2349,11 +2349,12 @@
 
   if (Vdrawnow_requested)
     Fdrawnow ();
+
+  return ovl ();
+  
 #else
   error ("__fltk_check__: not available without OpenGL and FLTK libraries");
 #endif
-
-  return octave_value ();
 }
 
 // Initialize the fltk graphics toolkit.
@@ -2382,11 +2383,11 @@
 
       fltk->set_input_event_hook_id (id);
     }
+
+  return ovl ();
 #else
   error ("__init_fltk__: not available without OpenGL and FLTK libraries");
 #endif
-
-  return octave_value ();
 }
 
 DEFUN_DLD (__have_fltk__, , ,
--- a/libinterp/octave-value/ov-fcn-handle.cc	Sun Dec 20 13:26:17 2015 -0800
+++ b/libinterp/octave-value/ov-fcn-handle.cc	Sun Dec 20 15:31:53 2015 -0800
@@ -1144,11 +1144,7 @@
             {
               if (H5Giterate (group_hid, "symbol table", &current_item,
                               hdf5_read_next_data, &dsub) <= 0)
-                {
-                  error ("load: failed to load anonymous function handle");
-                  success = false;
-                  break;
-                }
+                error ("load: failed to load anonymous function handle");
 
               symbol_table::assign (dsub.name, dsub.tc, local_scope);
             }
--- a/libinterp/octave-value/ov-java.cc	Sun Dec 20 13:26:17 2015 -0800
+++ b/libinterp/octave-value/ov-java.cc	Sun Dec 20 15:31:53 2015 -0800
@@ -2103,11 +2103,12 @@
 {
 #ifdef HAVE_JAVA
   terminate_jvm ();
+
+  return ovl ();
+
 #else
   error ("__java_init__: Octave was not compiled with Java interface");
 #endif
-
-  return octave_value ();
 }
 
 DEFUN (javaObject, args, ,
--- a/libinterp/octave.cc	Sun Dec 20 13:26:17 2015 -0800
+++ b/libinterp/octave.cc	Sun Dec 20 15:31:53 2015 -0800
@@ -709,7 +709,7 @@
   // Check for various incompatible argument pairs
   if (force_gui_option && no_gui_option)
     {
-      error ("only one of --force-gui and --no-gui may be used");
+      warning ("only one of --force-gui and --no-gui may be used");
 
       octave_print_terse_usage_and_exit ();
     }
@@ -717,7 +717,7 @@
   bool script_file = (argc - optind) > 0;
   if (! code_to_eval.empty () && script_file)
     {
-      error ("--eval \"CODE\" and script file are mutually exclusive options");
+      warning ("--eval \"CODE\" and script file are mutually exclusive options");
 
       octave_print_terse_usage_and_exit ();
     }
--- a/libinterp/parse-tree/lex.ll	Sun Dec 20 13:26:17 2015 -0800
+++ b/libinterp/parse-tree/lex.ll	Sun Dec 20 15:31:53 2015 -0800
@@ -1007,6 +1007,7 @@
 
     error ("unterminated character string constant");
 
+    // FIXME: This is no longer reachable now that error is exception based.
     return LEXICAL_ERROR;
   }
 
@@ -1059,6 +1060,7 @@
 
     error ("unterminated character string constant");
 
+    // FIXME: This is no longer reachable now that error is exception based.
     return LEXICAL_ERROR;
   }
 
@@ -2870,6 +2872,7 @@
   if (kw_token)
     {
       error ("method, class, and package names may not be keywords");
+      // FIXME: This is no longer reachable now that error is exception based.
       return LEXICAL_ERROR;
     }
 
@@ -2889,6 +2892,7 @@
   if (fq_identifier_contains_keyword (cls))
     {
       error ("class and package names may not be keywords");
+      // FIXME: This is no longer reachable now that error is exception based.
       return LEXICAL_ERROR;
     }
 
@@ -2908,6 +2912,7 @@
   if (fq_identifier_contains_keyword (tok))
     {
       error ("function, method, class, and package names may not be keywords");
+      // FIXME: This is no longer reachable now that error is exception based.
       return LEXICAL_ERROR;
     }
 
@@ -2957,7 +2962,7 @@
       if (kw_token)
         {
           error ("function handles may not refer to keywords");
-
+          // FIXME: This is no longer reachable now that error is exception based.
           return LEXICAL_ERROR;
         }
       else
@@ -3251,6 +3256,7 @@
 {
   error (msg);
 
+  // FIXME: This is no longer reachable now that error is exception based.
   OCTAVE_QUIT;
 
   yy_fatal_error (msg, scanner);
--- a/libinterp/parse-tree/oct-parse.in.yy	Sun Dec 20 13:26:17 2015 -0800
+++ b/libinterp/parse-tree/oct-parse.in.yy	Sun Dec 20 15:31:53 2015 -0800
@@ -4485,10 +4485,7 @@
   source_call_depth[file_full_name]++;
 
   if (source_call_depth[file_full_name] >= Vmax_recursion_depth)
-    {
-      error ("max_recursion_depth exceeded");
-      return;
-    }
+    error ("max_recursion_depth exceeded");
 
   if (! context.empty ())
     {