changeset 33383:e6806f30226a bytecode-interpreter

maint: merge default to bytecode-interpreter
author John W. Eaton <jwe@octave.org>
date Fri, 12 Apr 2024 12:07:28 -0400
parents 675d794e23b9 (current diff) 79cfa1b7a813 (diff)
children 625f40a7dca9
files libinterp/octave-value/ov.h libinterp/parse-tree/pt-eval.cc
diffstat 26 files changed, 139 insertions(+), 82 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/data.cc	Fri Apr 12 17:01:12 2024 +0200
+++ b/libinterp/corefcn/data.cc	Fri Apr 12 12:07:28 2024 -0400
@@ -8274,7 +8274,7 @@
       else if (array.is_uint64_type ())
         retval = array.uint64_array_value ().diff (order, dim);
       else
-        panic_impossible ();
+        error ("diff: unexpected integer type - please report this bug");
     }
   else if (array.issparse ())
     {
@@ -8544,7 +8544,7 @@
 #undef MAKE_INT_BRANCH
 
                     else
-                      panic_impossible ();
+                      error ("base_64_decode: unexpected integer type - please report this bug");
     }
   else if (args(0).is_single_type ())
     {
--- a/libinterp/corefcn/error.cc	Fri Apr 12 17:01:12 2024 +0200
+++ b/libinterp/corefcn/error.cc	Fri Apr 12 12:07:28 2024 -0400
@@ -753,7 +753,7 @@
   else if (all_state == "error")
     os << "By default, warnings are treated as errors.";
   else
-    panic_impossible ();
+    error ("unexpected default warning state '%s' - please report this bug", all_state.c_str ());
 
   if (nel > 1)
     {
--- a/libinterp/corefcn/find.cc	Fri Apr 12 17:01:12 2024 +0200
+++ b/libinterp/corefcn/find.cc	Fri Apr 12 12:07:28 2024 -0400
@@ -484,7 +484,7 @@
       DO_INT_BRANCH (uint32)
       DO_INT_BRANCH (uint64)
       else
-        panic_impossible ();
+        error ("find: unexpected integer type - please report this bug");
     }
   else if (arg.issparse ())
     {
--- a/libinterp/corefcn/graphics.in.h	Fri Apr 12 17:01:12 2024 +0200
+++ b/libinterp/corefcn/graphics.in.h	Fri Apr 12 12:07:28 2024 -0400
@@ -2252,7 +2252,7 @@
 
   virtual void init_integerhandle (const octave_value&)
   {
-    panic_impossible ();
+    error ("unexpected call to base_properties::init_integerhandle - please report this bug");
   }
 
   // Look through DEFAULTS for properties with given CLASS_NAME, and
@@ -2291,7 +2291,8 @@
 
   virtual bool has_property (const caseless_str&) const
   {
-    panic_impossible ();
+    error ("unexpected call to base_properties::has_property - please report this bug");
+
     return false;
   }
 
--- a/libinterp/corefcn/ls-hdf5.cc	Fri Apr 12 17:01:12 2024 +0200
+++ b/libinterp/corefcn/ls-hdf5.cc	Fri Apr 12 12:07:28 2024 -0400
@@ -84,6 +84,14 @@
   return static_cast<hid_t> (id);
 }
 
+#else
+
+OCTAVE_NORETURN static void
+error_unexpected (const char *name)
+{
+  error ("unexpected call to %s when HAVE_HDF5 is not defined - please report this bug", name);
+}
+
 #endif
 
 hdf5_fstreambase::hdf5_fstreambase (const char *name, int mode, int /* prot */)
@@ -112,10 +120,9 @@
     }
 
 #else
-  // This shouldn't happen because construction of hdf5_fstreambase
-  // objects is supposed to be impossible if HDF5 is not available.
 
-  panic_impossible ();
+  error_unexpected ("hdf5_fstreambase::close");
+
 #endif
 }
 
@@ -131,10 +138,9 @@
   current_item = 0;
 
 #else
-  // This shouldn't happen because construction of hdf5_fstreambase
-  // objects is supposed to be impossible if HDF5 is not available.
 
-  panic_impossible ();
+  error_unexpected ("hdf5_fstreambase::open");
+
 #endif
 }
 
@@ -231,10 +237,9 @@
   return;
 
 #else
-  // This shouldn't happen because construction of hdf5_fstreambase
-  // objects is supposed to be impossible if HDF5 is not available.
 
-  panic_impossible ();
+  error_unexpected ("hdf5_fstreambase::open_create");
+
 #endif
 }
 
--- a/libinterp/corefcn/oct-hist.cc	Fri Apr 12 17:01:12 2024 +0200
+++ b/libinterp/corefcn/oct-hist.cc	Fri Apr 12 12:07:28 2024 -0400
@@ -393,7 +393,7 @@
             }
 
           else
-            panic_impossible ();
+            error ("history: invalid option '%s' - please report this bug", option.c_str ());
 
           return hlist;
         }
--- a/libinterp/corefcn/oct-stream.cc	Fri Apr 12 17:01:12 2024 +0200
+++ b/libinterp/corefcn/oct-stream.cc	Fri Apr 12 12:07:28 2024 -0400
@@ -4421,7 +4421,7 @@
       break;
 
     default:
-      panic_impossible ();
+      error ("expecting format type to be one of 'e', 'f', 'g', 'E', or 'G' but found '%c' - please report this bug", fmt.type);
       break;
     }
 
@@ -4682,7 +4682,7 @@
                           else if (nr > 0)                              \
                             mval.resize (nr, max_size / nr, 0.0);       \
                           else                                          \
-                            panic_impossible ();                        \
+                            error ("unexpected size in character conversion - please report this bug"); \
                         }                                               \
                       else if (nr > 0)                                  \
                         mval.resize (nr, max_size / nr, 0.0);           \
@@ -4766,7 +4766,7 @@
             }
         }
       else
-        panic_impossible ();
+        error ("unexpected size in character conversion - please report this bug");
     }
   else if (nr > 0)
     {
@@ -4846,7 +4846,7 @@
                       else if (nr > 0)
                         mval.resize (nr, max_size / nr, 0.0);
                       else
-                        panic_impossible ();
+                        error ("unexpected size in character conversion - please report this bug");
                     }
                   else if (nr > 0)
                     mval.resize (nr, max_size / nr, 0.0);
--- a/libinterp/corefcn/pr-output.cc	Fri Apr 12 17:01:12 2024 +0200
+++ b/libinterp/corefcn/pr-output.cc	Fri Apr 12 12:07:28 2024 -0400
@@ -1775,7 +1775,7 @@
 octave_print_internal (std::ostream&, const float_display_format&,
                        char, bool)
 {
-  panic_impossible ();
+  error ("unexpected call to 'octave_print_internal (std::ostream&, const float_display_format&, char, bool)' - please report this bug");
 }
 
 void
@@ -3186,13 +3186,13 @@
 void
 octave_print_internal (std::ostream&, const Cell&, bool, int, bool)
 {
-  panic_impossible ();
+  error ("unexpected call to 'octave_print_internal (std::ostream&, const Cell&, bool, int, bool)' - please report this bug");
 }
 
 void
 octave_print_internal (std::ostream&, const octave_value&, bool)
 {
-  panic_impossible ();
+  error ("unexpected call to 'octave_print_internal (std::ostream&, const octave_value&, bool)' - please report this bug");
 }
 
 OCTAVE_BEGIN_NAMESPACE(octave)
--- a/libinterp/corefcn/quad.cc	Fri Apr 12 17:01:12 2024 +0200
+++ b/libinterp/corefcn/quad.cc	Fri Apr 12 12:07:28 2024 -0400
@@ -286,7 +286,7 @@
           break;
 
         default:
-          panic_impossible ();
+          error ("quad: unexpected nargin = %d - please report this bug", nargin);
           break;
         }
 
@@ -381,7 +381,7 @@
           break;
 
         default:
-          panic_impossible ();
+          error ("quad: unexpected nargin = %d - please report this bug", nargin);
           break;
         }
 
--- a/libinterp/dldfcn/__init_fltk__.cc	Fri Apr 12 17:01:12 2024 +0200
+++ b/libinterp/dldfcn/__init_fltk__.cc	Fri Apr 12 12:07:28 2024 -0400
@@ -124,6 +124,16 @@
 left double click - autoscale\n\
 ";
 
+#if ! defined (HAVE_OPENGL)
+
+OCTAVE_NORETURN static void
+error_unexpected (const char *name)
+{
+  error ("unexpected call to %s when HAVE_OPENGL is not defined - please report this bug", name);
+}
+
+#endif
+
 class OpenGL_fltk : public Fl_Gl_Window
 {
 public:
@@ -187,10 +197,7 @@
     octave_unused_parameter (ww);
     octave_unused_parameter (hh);
 
-    // This shouldn't happen because construction of Opengl_fltk
-    // objects is supposed to be impossible if OpenGL is not available.
-
-    panic_impossible ();
+    error_unexpected ("OpenGL_fltk::resize");
 
 #endif
   }
@@ -243,7 +250,7 @@
     // This shouldn't happen because construction of Opengl_fltk
     // objects is supposed to be impossible if OpenGL is not available.
 
-    panic_impossible ();
+    error_unexpected ("OpenGL_fltk::draw");
 
 #endif
   }
@@ -287,10 +294,7 @@
 
     octave_unused_parameter (event);
 
-    // This shouldn't happen because construction of Opengl_fltk
-    // objects is supposed to be impossible if OpenGL is not available.
-
-    panic_impossible ();
+    error_unexpected ("OpenGL_fltk::handle");
 
 #endif
   }
--- a/libinterp/octave-value/cdef-class.cc	Fri Apr 12 17:01:12 2024 +0200
+++ b/libinterp/octave-value/cdef-class.cc	Fri Apr 12 12:07:28 2024 -0400
@@ -811,7 +811,7 @@
           obj = empty_package;
         }
       else
-        panic_impossible ();
+        error ("expecting meta class, property, method, or package in cdef_class::cdef_class_rep::construct_object - please report this bug");
 
       return obj;
     }
--- a/libinterp/octave-value/cdef-utils.cc	Fri Apr 12 17:01:12 2024 +0200
+++ b/libinterp/octave-value/cdef-utils.cc	Fri Apr 12 12:07:28 2024 -0400
@@ -349,13 +349,13 @@
                       return false;
                     }
                   else
-                    panic_impossible ();
+                    error ("check_access: expecting private or protected access specifier - please report this bug");
                 }
 
               return false;
             }
           else
-            panic_impossible ();
+            error ("check_access: expecting a method or property name - please report this bug");
         }
     }
   else if (acc.isobject ())
--- a/libinterp/octave-value/ov.h	Fri Apr 12 17:01:12 2024 +0200
+++ b/libinterp/octave-value/ov.h	Fri Apr 12 12:07:28 2024 -0400
@@ -1833,7 +1833,12 @@
 
 template <typename Value>
 inline Value octave_value_extract (const octave_value&)
-{ panic_impossible (); }
+{
+  // We can't include error.h in ov.h.  Is there anything better than
+  // panic_impossible that we can do here?
+
+  panic_impossible ();
+}
 
 #define DEF_VALUE_EXTRACTOR(VALUE,MPREFIX)                              \
   template <>                                                           \
@@ -1900,6 +1905,9 @@
 DEF_VALUE_EXTRACTOR (SparseBoolMatrix, sparse_bool_matrix)
 #undef DEF_VALUE_EXTRACTOR
 
+// We can't include error.h in ov.h.  Is there anything better than
+// panic_impossible that we can do here?
+
 #define DEF_DUMMY_VALUE_EXTRACTOR(VALUE,DEFVAL)                         \
   template <>                                                           \
   inline VALUE octave_value_extract<VALUE> (const octave_value&)        \
--- a/libinterp/octave.cc	Fri Apr 12 17:01:12 2024 +0200
+++ b/libinterp/octave.cc	Fri Apr 12 12:07:28 2024 -0400
@@ -231,7 +231,8 @@
           // return '?', which is handled above.  If we end up here, it is
           // because there was an option but we forgot to handle it.
           // That should be fatal.
-          panic_impossible ();
+
+          error ("unexpected option (= %d) - please reportt this bug", optc);
           break;
         }
     }
--- a/libinterp/parse-tree/pt-anon-scopes.cc	Fri Apr 12 17:01:12 2024 +0200
+++ b/libinterp/parse-tree/pt-anon-scopes.cc	Fri Apr 12 12:07:28 2024 -0400
@@ -90,7 +90,7 @@
   // In visit_anon_fcn_handle we only accept/visit the body of
   // anonymous function definitions, not the parameter list.
 
-  panic_impossible ();
+  error ("unexpected call to tree_anon_scopes::visit_parameter_list - please report this bug");
 }
 
 void
@@ -99,7 +99,7 @@
   tree_command *cmd = stmt.command ();
 
   if (cmd)
-    panic_impossible ();
+    error ("unexpected call to tree_anon_scopes::visit_statement - please report this bug");
   else
     {
       tree_expression *expr = stmt.expression ();
--- a/libinterp/parse-tree/pt-array-list.cc	Fri Apr 12 17:01:12 2024 +0200
+++ b/libinterp/parse-tree/pt-array-list.cc	Fri Apr 12 12:07:28 2024 -0400
@@ -77,14 +77,15 @@
 tree_expression *
 tree_array_list::dup (symbol_scope&) const
 {
-  panic_impossible ();
+  error ("unexpected call to tree_array_list::dup - please report this bug");
+
   return nullptr;
 }
 
 void
 tree_array_list::accept (tree_walker&)
 {
-  panic_impossible ();
+  error ("unexpected call to tree_array_list::accept - please report this bug");
 }
 
 OCTAVE_END_NAMESPACE(octave)
--- a/libinterp/parse-tree/pt-assign.cc	Fri Apr 12 17:01:12 2024 +0200
+++ b/libinterp/parse-tree/pt-assign.cc	Fri Apr 12 12:07:28 2024 -0400
@@ -170,7 +170,8 @@
 tree_expression *
 tree_multi_assignment::dup (symbol_scope&) const
 {
-  panic_impossible ();
+  error ("unexpected call to tree_multi_assignment::dup - please report this bug");
+
   return nullptr;
 }
 
--- a/libinterp/parse-tree/pt-cmd.h	Fri Apr 12 17:01:12 2024 +0200
+++ b/libinterp/parse-tree/pt-cmd.h	Fri Apr 12 12:07:28 2024 -0400
@@ -52,7 +52,10 @@
 
   virtual ~tree_command () = default;
 
-  virtual void update_end_pos (const filepos&) { panic_impossible (); }
+  virtual void update_end_pos (const filepos&)
+  {
+    error ("unexpected call to tree_command::update_end_pos - please report this bug");
+  }
 };
 
 // No-op.
@@ -77,7 +80,7 @@
     if (is_end_of_fcn_or_script () || is_end_of_file ())
       m_tok.end_pos (pos);
     else
-      panic_impossible ();
+      error ("unexpected call to tree_no_op_command::update_end_pos - please report this bug");
   }
 
   comment_list leading_comments () const { return m_tok.leading_comments (); }
--- a/libinterp/parse-tree/pt-eval.cc	Fri Apr 12 17:01:12 2024 +0200
+++ b/libinterp/parse-tree/pt-eval.cc	Fri Apr 12 12:07:28 2024 -0400
@@ -3676,7 +3676,7 @@
           args = args.slice (1, nargin, true);
         }
       else
-        panic_impossible ();
+        error ("invalid call to classdef constructor in tree_evaluator::execute_user_function - please report this bug");
     }
 
   tree_parameter_list *param_list = user_function.parameter_list ();
@@ -4454,7 +4454,7 @@
   tree_expression *expr = cmd.condition ();
 
   if (! expr)
-    panic_impossible ();
+    error ("unexpected: while condition is nullptr - please report this bug");
 
   for (;;)
     {
@@ -4497,7 +4497,7 @@
   tree_expression *expr = cmd.condition ();
 
   if (! expr)
-    panic_impossible ();
+    error ("unexpected: do-until condition is nullptr - please report this bug");
 
   for (;;)
     {
--- a/libinterp/parse-tree/pt-idx.cc	Fri Apr 12 17:01:12 2024 +0200
+++ b/libinterp/parse-tree/pt-idx.cc	Fri Apr 12 12:07:28 2024 -0400
@@ -182,7 +182,7 @@
           fn = t.xstring_value ("dynamic structure field names must be strings");
         }
       else
-        panic_impossible ();
+        error ("unexpected: DF is nullptr in call to tree_index_expression::get_struct_index - please report this bug");
     }
 
   return fn;
@@ -245,7 +245,7 @@
           break;
 
         default:
-          panic_impossible ();
+          error ("unexpected: index not '(', '{', or '.' in tree_index_expression::lvalue - please report this bug");
         }
 
       if (idx.back ().empty ())
@@ -609,7 +609,7 @@
             break;
 
           default:
-            panic_impossible ();
+            error ("unexpected: index not '(', '{', or '.' in tree_index_expression::evaluate_n - please report this bug");
           }
 
         p_args++;
--- a/libinterp/parse-tree/pt-stmt.cc	Fri Apr 12 17:01:12 2024 +0200
+++ b/libinterp/parse-tree/pt-stmt.cc	Fri Apr 12 12:07:28 2024 -0400
@@ -132,7 +132,7 @@
   if (m_command)
     m_command->update_end_pos (pos);
   else
-    panic_impossible ();
+    error ("unexpected call to tree_statement::update_end_pos - please report this bug");
 }
 
 std::string
--- a/libinterp/parse-tree/pt-walk.cc	Fri Apr 12 17:01:12 2024 +0200
+++ b/libinterp/parse-tree/pt-walk.cc	Fri Apr 12 12:07:28 2024 -0400
@@ -442,7 +442,7 @@
           break;
 
         default:
-          panic_impossible ();
+          error ("unexpected: index not '(', '{', or '.' in tree_walker::visit_index_expression - please report this bug");
         }
 
       p_arg_lists++;
--- a/liboctave/array/Sparse.cc	Fri Apr 12 17:01:12 2024 +0200
+++ b/liboctave/array/Sparse.cc	Fri Apr 12 12:07:28 2024 -0400
@@ -2754,7 +2754,7 @@
         break;
       }
     default:
-      liboctave_panic_impossible ();
+      (*current_liboctave_error_handler) ("Sparse<T, Alloc>::cat: invalid dimension = %d - please report this bug", dim);
     }
 
   return retval;
--- a/liboctave/array/idx-vector.cc	Fri Apr 12 17:01:12 2024 +0200
+++ b/liboctave/array/idx-vector.cc	Fri Apr 12 12:07:28 2024 -0400
@@ -1042,6 +1042,10 @@
 
   switch (m_rep->idx_class ())
     {
+    case class_invalid:
+      (*current_liboctave_error_handler) ("unexpected: invalid index");
+      break;
+
     case class_colon:
       (*current_liboctave_error_handler) ("colon not allowed");
       break;
@@ -1087,9 +1091,9 @@
       }
       break;
 
-    default:
-      liboctave_panic_impossible ();
-      break;
+      // We should have handled all possible enum values above.  Rely on
+      // compiler diagnostics to warn if we haven't.  For example, GCC's
+      // -Wswitch option, enabled by -Wall, will provide a warning.
     }
 }
 
@@ -1220,6 +1224,10 @@
   iclass = idx_class ();
   switch (iclass)
     {
+    case class_invalid:
+      (*current_liboctave_error_handler) ("unexpected: invalid index");
+      break;
+
     case class_colon:
       break;
 
@@ -1251,9 +1259,9 @@
       }
       break;
 
-    default:
-      liboctave_panic_impossible ();
-      break;
+      // We should have handled all possible enum values above.  Rely on
+      // compiler diagnostics to warn if we haven't.  For example, GCC's
+      // -Wswitch option, enabled by -Wall, will provide a warning.
     }
 }
 
--- a/liboctave/array/idx-vector.h	Fri Apr 12 17:01:12 2024 +0200
+++ b/liboctave/array/idx-vector.h	Fri Apr 12 12:07:28 2024 -0400
@@ -587,6 +587,10 @@
 
     switch (m_rep->idx_class ())
       {
+      case class_invalid:
+        (*current_liboctave_error_handler) ("unexpected: invalid index");
+        break;
+
       case class_colon:
         std::copy_n (src, len, dest);
         break;
@@ -637,9 +641,10 @@
         }
         break;
 
-      default:
-        liboctave_panic_impossible ();
-        break;
+        // We should have handled all possible enum values above.  Rely
+        // on compiler diagnostics to warn if we haven't.  For example,
+        // GCC's -Wswitch option, enabled by -Wall, will provide a
+        // warning.
       }
 
     return len;
@@ -661,6 +666,10 @@
 
     switch (m_rep->idx_class ())
       {
+      case class_invalid:
+        (*current_liboctave_error_handler) ("unexpected: invalid index");
+        break;
+
       case class_colon:
         std::copy_n (src, len, dest);
         break;
@@ -709,9 +718,10 @@
         }
         break;
 
-      default:
-        liboctave_panic_impossible ();
-        break;
+        // We should have handled all possible enum values above.  Rely
+        // on compiler diagnostics to warn if we haven't.  For example,
+        // GCC's -Wswitch option, enabled by -Wall, will provide a
+        // warning.
       }
 
     return len;
@@ -733,6 +743,10 @@
 
     switch (m_rep->idx_class ())
       {
+      case class_invalid:
+        (*current_liboctave_error_handler) ("unexpected: invalid index");
+        break;
+
       case class_colon:
         std::fill_n (dest, len, val);
         break;
@@ -781,9 +795,10 @@
         }
         break;
 
-      default:
-        liboctave_panic_impossible ();
-        break;
+        // We should have handled all possible enum values above.  Rely
+        // on compiler diagnostics to warn if we haven't.  For example,
+        // GCC's -Wswitch option, enabled by -Wall, will provide a
+        // warning.
       }
 
     return len;
@@ -803,6 +818,10 @@
 
     switch (m_rep->idx_class ())
       {
+      case class_invalid:
+        (*current_liboctave_error_handler) ("unexpected: invalid index");
+        break;
+
       case class_colon:
         for (octave_idx_type i = 0; i < len; i++) body (i);
         break;
@@ -847,9 +866,10 @@
         }
         break;
 
-      default:
-        liboctave_panic_impossible ();
-        break;
+        // We should have handled all possible enum values above.  Rely
+        // on compiler diagnostics to warn if we haven't.  For example,
+        // GCC's -Wswitch option, enabled by -Wall, will provide a
+        // warning.
       }
 
   }
@@ -871,6 +891,10 @@
 
     switch (m_rep->idx_class ())
       {
+      case class_invalid:
+        (*current_liboctave_error_handler) ("unexpected: invalid index");
+        break;
+
       case class_colon:
         {
           octave_idx_type i;
@@ -933,9 +957,10 @@
         }
         break;
 
-      default:
-        liboctave_panic_impossible ();
-        break;
+        // We should have handled all possible enum values above.  Rely
+        // on compiler diagnostics to warn if we haven't.  For example,
+        // GCC's -Wswitch option, enabled by -Wall, will provide a
+        // warning.
       }
 
     return ret;
--- a/liboctave/numeric/Quad.cc	Fri Apr 12 17:01:12 2024 +0200
+++ b/liboctave/numeric/Quad.cc	Fri Apr 12 12:07:28 2024 -0400
@@ -169,9 +169,9 @@
       inf = 2;
       break;
 
-    default:
-      liboctave_panic_impossible ();
-      break;
+      // We should have handled all possible enum values above.  Rely on
+      // compiler diagnostics to warn if we haven't.  For example, GCC's
+      // -Wswitch option, enabled by -Wall, will provide a warning.
     }
 
   double abs_tol = absolute_tolerance ();
@@ -286,9 +286,9 @@
       inf = 2;
       break;
 
-    default:
-      liboctave_panic_impossible ();
-      break;
+      // We should have handled all possible enum values above.  Rely on
+      // compiler diagnostics to warn if we haven't.  For example, GCC's
+      // -Wswitch option, enabled by -Wall, will provide a warning.
     }
 
   float abs_tol = single_precision_absolute_tolerance ();