changeset 33351:1941a21c23b9 bytecode-interpreter

maint: merge default to bytecode-interpreter
author John W. Eaton <jwe@octave.org>
date Sun, 07 Apr 2024 13:40:32 -0400
parents e8854b8d2486 (current diff) 05da909b8c28 (diff)
children 09f32949dcb7
files libinterp/parse-tree/pt-eval.cc
diffstat 4 files changed, 190 insertions(+), 142 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/gl-render.cc	Sat Apr 06 17:38:27 2024 -0400
+++ b/libinterp/corefcn/gl-render.cc	Sun Apr 07 13:40:32 2024 -0400
@@ -678,6 +678,12 @@
   // Dummy class.
 };
 
+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
 
 opengl_renderer::opengl_renderer (opengl_functions& glfcns)
@@ -895,7 +901,7 @@
   // This shouldn't happen because construction of opengl_renderer
   // objects is supposed to be impossible if OpenGL is not available.
 
-  panic_impossible ();
+  error_unexpected ("opengl_renderer::init_gl_context");
 
 #endif
 }
@@ -971,7 +977,7 @@
   // This shouldn't happen because construction of opengl_renderer
   // objects is supposed to be impossible if OpenGL is not available.
 
-  panic_impossible ();
+  error_unexpected ("opengl_renderer::render_grid");
 
 #endif
 }
@@ -1053,7 +1059,7 @@
   // This shouldn't happen because construction of opengl_renderer
   // objects is supposed to be impossible if OpenGL is not available.
 
-  panic_impossible ();
+  error_unexpected ("opengl_renderer::render_tickmarks");
 
 #endif
 }
@@ -1123,7 +1129,7 @@
   // This shouldn't happen because construction of opengl_renderer
   // objects is supposed to be impossible if OpenGL is not available.
 
-  panic_impossible ();
+  error_unexpected ("opengl_renderer::render_ticktexts");
 
 #endif
 }
@@ -1149,7 +1155,7 @@
   // This shouldn't happen because construction of opengl_renderer
   // objects is supposed to be impossible if OpenGL is not available.
 
-  panic_impossible ();
+  error_unexpected ("opengl_renderer::draw_zoom_rect");
 
 #endif
 }
@@ -1214,7 +1220,7 @@
   // This shouldn't happen because construction of opengl_renderer
   // objects is supposed to be impossible if OpenGL is not available.
 
-  panic_impossible ();
+  error_unexpected ("opengl_renderer::draw_zoom_box");
 
 #endif
 }
@@ -1251,7 +1257,7 @@
   octave_unused_parameter (width);
   octave_unused_parameter (height);
 
-  panic_impossible ();
+  error_unexpected ("opengl_renderer::get_pixels");
 
 #endif
 }
@@ -1268,7 +1274,7 @@
   // This shouldn't happen because construction of opengl_renderer
   // objects is supposed to be impossible if OpenGL is not available.
 
-  panic_impossible ();
+  error_unexpected ("opengl_renderer::finish");
 
 #endif
 }
@@ -1326,7 +1332,7 @@
   // This shouldn't happen because construction of opengl_renderer
   // objects is supposed to be impossible if OpenGL is not available.
 
-  panic_impossible ();
+  error_unexpected ("opengl_renderer::setup_opengl_transformation");
 
 #endif
 }
@@ -1386,7 +1392,7 @@
   // This shouldn't happen because construction of opengl_renderer
   // objects is supposed to be impossible if OpenGL is not available.
 
-  panic_impossible ();
+  error_unexpected ("opengl_renderer::draw_axes_planes");
 
 #endif
 }
@@ -1546,7 +1552,7 @@
   // This shouldn't happen because construction of opengl_renderer
   // objects is supposed to be impossible if OpenGL is not available.
 
-  panic_impossible ();
+  error_unexpected ("opengl_renderer::draw_axes_boxes");
 
 #endif
 }
@@ -1747,7 +1753,7 @@
   // This shouldn't happen because construction of opengl_renderer
   // objects is supposed to be impossible if OpenGL is not available.
 
-  panic_impossible ();
+  error_unexpected ("opengl_renderer::draw_axes_x_grid");
 
 #endif
 }
@@ -1949,7 +1955,7 @@
   // This shouldn't happen because construction of opengl_renderer
   // objects is supposed to be impossible if OpenGL is not available.
 
-  panic_impossible ();
+  error_unexpected ("opengl_renderer::draw_axes_y_grid");
 
 #endif
 }
@@ -2174,7 +2180,7 @@
   // This shouldn't happen because construction of opengl_renderer
   // objects is supposed to be impossible if OpenGL is not available.
 
-  panic_impossible ();
+  error_unexpected ("opengl_renderer::draw_axes_grids");
 
 #endif
 }
@@ -2221,7 +2227,7 @@
   // This shouldn't happen because construction of opengl_renderer
   // objects is supposed to be impossible if OpenGL is not available.
 
-  panic_impossible ();
+  error_unexpected ("opengl_renderer::draw_all_lights");
 
 #endif
 }
@@ -2310,7 +2316,7 @@
   // This shouldn't happen because construction of opengl_renderer
   // objects is supposed to be impossible if OpenGL is not available.
 
-  panic_impossible ();
+  error_unexpected ("opengl_renderer::draw_axes_children");
 
 #endif
 }
@@ -2382,7 +2388,7 @@
   // This shouldn't happen because construction of opengl_renderer
   // objects is supposed to be impossible if OpenGL is not available.
 
-  panic_impossible ();
+  error_unexpected ("opengl_renderer::draw_axes");
 
 #endif
 }
@@ -2528,7 +2534,7 @@
   // This shouldn't happen because construction of opengl_renderer
   // objects is supposed to be impossible if OpenGL is not available.
 
-  panic_impossible ();
+  error_unexpected ("opengl_renderer::draw_line");
 
 #endif
 }
@@ -3193,7 +3199,7 @@
   // This shouldn't happen because construction of opengl_renderer
   // objects is supposed to be impossible if OpenGL is not available.
 
-  panic_impossible ();
+  error_unexpected ("opengl_renderer::draw_surface");
 
 #endif
 }
@@ -3740,7 +3746,7 @@
   // This shouldn't happen because construction of opengl_renderer
   // objects is supposed to be impossible if OpenGL is not available.
 
-  panic_impossible ();
+  error_unexpected ("opengl_renderer::draw_patch");
 
 #endif
 }
@@ -3849,7 +3855,7 @@
   // This shouldn't happen because construction of opengl_renderer
   // objects is supposed to be impossible if OpenGL is not available.
 
-  panic_impossible ();
+  error_unexpected ("opengl_renderer::draw_scatter");
 
 #endif
 }
@@ -3886,7 +3892,7 @@
   // This shouldn't happen because construction of opengl_renderer
   // objects is supposed to be impossible if OpenGL is not available.
 
-  panic_impossible ();
+  error_unexpected ("opengl_renderer::draw_light");
 
 #endif
 }
@@ -3917,7 +3923,7 @@
   // This shouldn't happen because construction of opengl_renderer
   // objects is supposed to be impossible if OpenGL is not available.
 
-  panic_impossible ();
+  error_unexpected ("opengl_renderer::set_ortho_coordinates");
 
 #endif
 }
@@ -3938,7 +3944,7 @@
   // This shouldn't happen because construction of opengl_renderer
   // objects is supposed to be impossible if OpenGL is not available.
 
-  panic_impossible ();
+  error_unexpected ("opengl_renderer::restore_previous_coordinates");
 
 #endif
 }
@@ -3976,7 +3982,7 @@
   // This shouldn't happen because construction of opengl_renderer
   // objects is supposed to be impossible if OpenGL is not available.
 
-  panic_impossible ();
+  error_unexpected ("opengl_renderer::draw_text");
 
 #endif
 }
@@ -4062,7 +4068,7 @@
   // This shouldn't happen because construction of opengl_renderer
   // objects is supposed to be impossible if OpenGL is not available.
 
-  panic_impossible ();
+  error_unexpected ("opengl_renderer::draw_text_background");
 
 #endif
 }
@@ -4085,7 +4091,7 @@
   // This shouldn't happen because construction of opengl_renderer
   // objects is supposed to be impossible if OpenGL is not available.
 
-  panic_impossible ();
+  error_unexpected ("opengl_renderer::draw_image");
 
 #endif
 }
@@ -4168,7 +4174,7 @@
   // This shouldn't happen because construction of opengl_renderer
   // objects is supposed to be impossible if OpenGL is not available.
 
-  panic_impossible ();
+  error_unexpected ("opengl_renderer::draw_texture_image");
 
 #endif
 }
@@ -4204,7 +4210,7 @@
   // This shouldn't happen because construction of opengl_renderer
   // objects is supposed to be impossible if OpenGL is not available.
 
-  panic_impossible ();
+  error_unexpected ("opengl_renderer::set_viewport");
 
 #endif
 }
@@ -4231,7 +4237,7 @@
   // This shouldn't happen because construction of opengl_renderer
   // objects is supposed to be impossible if OpenGL is not available.
 
-  panic_impossible ();
+  error_unexpected ("opengl_renderer::get_viewport_scaled");
 
 #endif
 
@@ -4255,7 +4261,7 @@
   // This shouldn't happen because construction of opengl_renderer
   // objects is supposed to be impossible if OpenGL is not available.
 
-  panic_impossible ();
+  error_unexpected ("opengl_renderer::set_color");
 
 #endif
 }
@@ -4297,7 +4303,7 @@
   // This shouldn't happen because construction of opengl_renderer
   // objects is supposed to be impossible if OpenGL is not available.
 
-  panic_impossible ();
+  error_unexpected ("opengl_renderer::set_polygon_offset");
 
 #endif
 }
@@ -4316,7 +4322,7 @@
   // This shouldn't happen because construction of opengl_renderer
   // objects is supposed to be impossible if OpenGL is not available.
 
-  panic_impossible ();
+  error_unexpected ("opengl_renderer::set_linewidth");
 
 #endif
 }
@@ -4377,7 +4383,7 @@
   // This shouldn't happen because construction of opengl_renderer
   // objects is supposed to be impossible if OpenGL is not available.
 
-  panic_impossible ();
+  error_unexpected ("opengl_renderer::set_linestyle");
 
 #endif
 }
@@ -4427,7 +4433,7 @@
   // This shouldn't happen because construction of opengl_renderer
   // objects is supposed to be impossible if OpenGL is not available.
 
-  panic_impossible ();
+  error_unexpected ("opengl_renderer::set_clipbox");
 
 #endif
 }
@@ -4456,7 +4462,7 @@
   // This shouldn't happen because construction of opengl_renderer
   // objects is supposed to be impossible if OpenGL is not available.
 
-  panic_impossible ();
+  error_unexpected ("opengl_renderer::set_clipping");
 
 #endif
 }
@@ -4489,7 +4495,7 @@
   // This shouldn't happen because construction of opengl_renderer
   // objects is supposed to be impossible if OpenGL is not available.
 
-  panic_impossible ();
+  error_unexpected ("opengl_renderer::init_marker");
 
 #endif
 }
@@ -4510,7 +4516,7 @@
   // This shouldn't happen because construction of opengl_renderer
   // objects is supposed to be impossible if OpenGL is not available.
 
-  panic_impossible ();
+  error_unexpected ("opengl_renderer::change_marker");
 
 #endif
 }
@@ -4534,7 +4540,7 @@
   // This shouldn't happen because construction of opengl_renderer
   // objects is supposed to be impossible if OpenGL is not available.
 
-  panic_impossible ();
+  error_unexpected ("opengl_renderer::end_marker");
 
 #endif
 }
@@ -4586,7 +4592,7 @@
   // This shouldn't happen because construction of opengl_renderer
   // objects is supposed to be impossible if OpenGL is not available.
 
-  panic_impossible ();
+  error_unexpected ("opengl_renderer::draw_marker");
 
 #endif
 }
@@ -4609,7 +4615,7 @@
   // This shouldn't happen because construction of opengl_renderer
   // objects is supposed to be impossible if OpenGL is not available.
 
-  panic_impossible ();
+  error_unexpected ("opengl_renderer::init_maxlights");
 
 #endif
 }
@@ -4636,7 +4642,7 @@
   // This shouldn't happen because construction of opengl_renderer
   // objects is supposed to be impossible if OpenGL is not available.
 
-  panic_impossible ();
+  error_unexpected ("opengl_renderer::get_string");
   return std::string ();
 
 #endif
@@ -4671,7 +4677,7 @@
   // This shouldn't happen because construction of opengl_renderer
   // objects is supposed to be impossible if OpenGL is not available.
 
-  panic_impossible ();
+  error_unexpected ("opengl_renderer::set_normal");
 
 #endif
 }
@@ -4885,7 +4891,7 @@
   // This shouldn't happen because construction of opengl_renderer
   // objects is supposed to be impossible if OpenGL is not available.
 
-  panic_impossible ();
+  error_unexpected ("opengl_renderer::make_marker_list");
 
 #endif
 }
@@ -4945,7 +4951,7 @@
   // This shouldn't happen because construction of opengl_renderer
   // objects is supposed to be impossible if OpenGL is not available.
 
-  panic_impossible ();
+  error_unexpected ("opengl_renderer::render_text");
 
 #endif
 }
@@ -5001,7 +5007,7 @@
   // This shouldn't happen because construction of opengl_renderer
   // objects is supposed to be impossible if OpenGL is not available.
 
-  panic_impossible ();
+  error_unexpected ("opengl_renderer::render_text");
 
 #endif
 }
--- a/libinterp/parse-tree/oct-parse.yy	Sat Apr 06 17:38:27 2024 -0400
+++ b/libinterp/parse-tree/oct-parse.yy	Sun Apr 07 13:40:32 2024 -0400
@@ -2480,6 +2480,12 @@
   m_parser_state = yypstate_new ();
 }
 
+OCTAVE_NORETURN static void
+unexpected_token (int tok_id, const char *where)
+{
+  error ("unexpected token (= %d) in %s - please report this bug", tok_id, where);
+}
+
 // Error messages for mismatched end tokens.
 
 static std::string
@@ -2493,6 +2499,10 @@
       retval = "end";
       break;
 
+    case token::arguments_end:
+      retval = "endarguments";
+      break;
+
     case token::classdef_end:
       retval = "endclassdef";
       break;
@@ -2549,9 +2559,9 @@
       retval = "endwhile";
       break;
 
-    default:
-      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 retval;
@@ -2628,11 +2638,11 @@
 tree_constant *
 base_parser::make_constant (token *tok)
 {
-  int op = tok->token_id ();
+  int tok_id = tok->token_id ();
 
   tree_constant *retval = nullptr;
 
-  switch (op)
+  switch (tok_id)
     {
     case ':':
       retval = new tree_constant (octave_value (octave_value::magic_colon_t), *tok);
@@ -2647,18 +2657,18 @@
       {
         std::string txt = tok->text ();
 
-        char delim = op == DQ_STRING ? '"' : '\'';
+        char delim = tok_id == DQ_STRING ? '"' : '\'';
         octave_value tmp (txt, delim);
 
         if (txt.empty ())
           {
-            if (op == DQ_STRING)
+            if (tok_id == DQ_STRING)
               tmp = octave_null_str::instance;
             else
               tmp = octave_null_sq_str::instance;
           }
 
-        if (op == DQ_STRING)
+        if (tok_id == DQ_STRING)
           txt = undo_string_escapes (txt);
 
         // FIXME: maybe the addition of delims should be handled by
@@ -2669,7 +2679,7 @@
       break;
 
     default:
-      panic_impossible ();
+      unexpected_token (tok_id, "base_parser::make_constant");
       break;
     }
 
@@ -2837,7 +2847,9 @@
 {
   octave_value::binary_op t = octave_value::unknown_binary_op;
 
-  switch (op_tok->token_id ())
+  int tok_id = op_tok->token_id ();
+
+  switch (tok_id)
     {
     case POW:
       t = octave_value::op_pow;
@@ -2912,7 +2924,7 @@
       break;
 
     default:
-      panic_impossible ();
+      unexpected_token (tok_id, "base_parser::make_binary_op");
       break;
     }
 
@@ -2957,7 +2969,9 @@
 {
   tree_boolean_expression::type t;
 
-  switch (op_tok->token_id ())
+  int tok_id = op_tok->token_id ();
+
+  switch (tok_id)
     {
     case EXPR_AND_AND:
       t = tree_boolean_expression::bool_and;
@@ -2968,7 +2982,7 @@
       break;
 
     default:
-      panic_impossible ();
+      unexpected_token (tok_id, "base_parser::make_boolean_op");
       break;
     }
 
@@ -2982,7 +2996,9 @@
 {
   octave_value::unary_op t = octave_value::unknown_unary_op;
 
-  switch (op_tok->token_id ())
+  int tok_id = op_tok->token_id ();
+
+  switch (tok_id)
     {
     case '~':
     case '!':
@@ -3006,7 +3022,7 @@
       break;
 
     default:
-      panic_impossible ();
+      unexpected_token (tok_id, "base_parser::make_prefix_op");
       break;
     }
 
@@ -3020,7 +3036,9 @@
 {
   octave_value::unary_op t = octave_value::unknown_unary_op;
 
-  switch (op_tok->token_id ())
+  int tok_id = op_tok->token_id ();
+
+  switch (tok_id)
     {
     case HERMITIAN:
       t = octave_value::op_hermitian;
@@ -3039,7 +3057,7 @@
       break;
 
     default:
-      panic_impossible ();
+      unexpected_token (tok_id, "base_parser::make_postfix_op");
       break;
     }
 
@@ -3379,7 +3397,9 @@
 {
   octave_value::assign_op t = octave_value::unknown_assign_op;
 
-  switch (eq_tok->token_id ())
+  int tok_id = eq_tok->token_id ();
+
+  switch (tok_id)
     {
     case '=':
       t = octave_value::op_asn_eq;
@@ -3434,7 +3454,7 @@
       break;
 
     default:
-      panic_impossible ();
+      unexpected_token (tok_id, "base_parser::make_assign_op");
       break;
     }
 
@@ -4520,6 +4540,8 @@
   if (lst)
     m_lexer.mark_as_variables (lst->variable_names ());
 
+  int tok_id = tok->token_id ();
+
   switch (tok->token_id ())
     {
     case GLOBAL:
@@ -4548,7 +4570,7 @@
       break;
 
     default:
-      panic_impossible ();
+      unexpected_token (tok_id, "base_parser::make_decl_command");
       break;
     }
 
@@ -5281,7 +5303,7 @@
       // table?).  Return pointer to constructor?
 
       if (ov_fcn.is_defined ())
-        panic_impossible ();
+        error ("unexpected: defining classdef object but primary_fcn is already defined - please report this bug");
 
       bool is_at_folder = ! dispatch_type.empty ();
 
--- a/libinterp/parse-tree/pt-bp.cc	Sat Apr 06 17:38:27 2024 -0400
+++ b/libinterp/parse-tree/pt-bp.cc	Sun Apr 07 13:40:32 2024 -0400
@@ -33,6 +33,12 @@
 
 OCTAVE_BEGIN_NAMESPACE(octave)
 
+OCTAVE_NORETURN static void
+error_unexpected (const char *name)
+{
+  error ("unexpected call to %s - please report this bug", name);
+}
+
 void
 tree_breakpoint::visit_while_command (tree_while_command& cmd)
 {
@@ -69,7 +75,7 @@
 void
 tree_breakpoint::visit_argument_list (tree_argument_list&)
 {
-  panic_impossible ();
+  error_unexpected ("tree_breakpoint::visit_argument_list");
 }
 
 void
@@ -81,37 +87,37 @@
 void
 tree_breakpoint::visit_args_block_attribute_list (tree_args_block_attribute_list&)
 {
-  panic_impossible ();
+  error_unexpected ("tree_breakpoint::visit_args_block_attribute_list");
 }
 
 void
 tree_breakpoint::visit_args_block_validation_list (tree_args_block_validation_list&)
 {
-  panic_impossible ();
+  error_unexpected ("tree_breakpoint::visit_args_block_validation_list");
 }
 
 void
 tree_breakpoint::visit_arg_validation (tree_arg_validation&)
 {
-  panic_impossible ();
+  error_unexpected ("tree_breakpoint::visit_arg_validation");
 }
 
 void
 tree_breakpoint::visit_arg_size_spec (tree_arg_size_spec&)
 {
-  panic_impossible ();
+  error_unexpected ("tree_breakpoint::visit_arg_size_spec");
 }
 
 void
 tree_breakpoint::visit_arg_validation_fcns (tree_arg_validation_fcns&)
 {
-  panic_impossible ();
+  error_unexpected ("tree_breakpoint::visit_arg_validation_fcns");
 }
 
 void
 tree_breakpoint::visit_binary_expression (tree_binary_expression&)
 {
-  panic_impossible ();
+  error_unexpected ("tree_breakpoint::visit_binary_expression");
 }
 
 void
@@ -124,7 +130,7 @@
 void
 tree_breakpoint::visit_colon_expression (tree_colon_expression&)
 {
-  panic_impossible ();
+  error_unexpected ("tree_breakpoint::visit_colon_expression");
 }
 
 void
@@ -144,13 +150,13 @@
 void
 tree_breakpoint::visit_decl_init_list (tree_decl_init_list&)
 {
-  panic_impossible ();
+  error_unexpected ("tree_breakpoint::visit_decl_init_list");
 }
 
 void
 tree_breakpoint::visit_decl_elt (tree_decl_elt&)
 {
-  panic_impossible ();
+  error_unexpected ("tree_breakpoint::visit_decl_elt");
 }
 
 void
@@ -186,25 +192,25 @@
 void
 tree_breakpoint::visit_octave_user_function_header (octave_user_function&)
 {
-  panic_impossible ();
+  error_unexpected ("tree_breakpoint::visit_octave_user_function_header");
 }
 
 void
 tree_breakpoint::visit_octave_user_function_trailer (octave_user_function&)
 {
-  panic_impossible ();
+  error_unexpected ("tree_breakpoint::visit_octave_user_function_trailer");
 }
 
 void
 tree_breakpoint::visit_identifier (tree_identifier&)
 {
-  panic_impossible ();
+  error_unexpected ("tree_breakpoint::visit_identifier");
 }
 
 void
 tree_breakpoint::visit_if_clause (tree_if_clause&)
 {
-  panic_impossible ();
+  error_unexpected ("tree_breakpoint::visit_if_clause");
 }
 
 void
@@ -231,25 +237,25 @@
 void
 tree_breakpoint::visit_index_expression (tree_index_expression&)
 {
-  panic_impossible ();
+  error_unexpected ("tree_breakpoint::visit_index_expression");
 }
 
 void
 tree_breakpoint::visit_matrix (tree_matrix&)
 {
-  panic_impossible ();
+  error_unexpected ("tree_breakpoint::visit_matrix");
 }
 
 void
 tree_breakpoint::visit_cell (tree_cell&)
 {
-  panic_impossible ();
+  error_unexpected ("tree_breakpoint::visit_cell");
 }
 
 void
 tree_breakpoint::visit_multi_assignment (tree_multi_assignment&)
 {
-  panic_impossible ();
+  error_unexpected ("tree_breakpoint::visit_multi_assignment");
 }
 
 void
@@ -262,37 +268,37 @@
 void
 tree_breakpoint::visit_anon_fcn_handle (tree_anon_fcn_handle&)
 {
-  panic_impossible ();
+  error_unexpected ("tree_breakpoint::visit_anon_fcn_handle");
 }
 
 void
 tree_breakpoint::visit_constant (tree_constant&)
 {
-  panic_impossible ();
+  error_unexpected ("tree_breakpoint::visit_constant");
 }
 
 void
 tree_breakpoint::visit_fcn_handle (tree_fcn_handle&)
 {
-  panic_impossible ();
+  error_unexpected ("tree_breakpoint::visit_fcn_handle");
 }
 
 void
 tree_breakpoint::visit_parameter_list (tree_parameter_list&)
 {
-  panic_impossible ();
+  error_unexpected ("tree_breakpoint::visit_parameter_list");
 }
 
 void
 tree_breakpoint::visit_postfix_expression (tree_postfix_expression&)
 {
-  panic_impossible ();
+  error_unexpected ("tree_breakpoint::visit_postfix_expression");
 }
 
 void
 tree_breakpoint::visit_prefix_expression (tree_prefix_expression&)
 {
-  panic_impossible ();
+  error_unexpected ("tree_breakpoint::visit_prefix_expression");
 }
 
 void
@@ -305,7 +311,7 @@
 void
 tree_breakpoint::visit_simple_assignment (tree_simple_assignment&)
 {
-  panic_impossible ();
+  error_unexpected ("tree_breakpoint::visit_simple_assignment");
 }
 
 void
@@ -345,7 +351,7 @@
 void
 tree_breakpoint::visit_switch_case (tree_switch_case&)
 {
-  panic_impossible ();
+  error_unexpected ("tree_breakpoint::visit_switch_case");
 }
 
 void
@@ -421,30 +427,34 @@
 void
 tree_breakpoint::take_action (tree& tr)
 {
-  if (m_action == set)
+  switch (m_action)
     {
+    case set:
       tr.set_breakpoint (m_condition);
       m_line = tr.line ();
       m_found = true;
-    }
-  else if (m_action == clear)
-    {
+      break;
+
+    case clear:
       if (tr.is_breakpoint ())
         {
           tr.delete_breakpoint ();
           m_found = true;
         }
-    }
-  else if (m_action == list)
-    {
+      break;
+
+    case list:
       if (tr.is_breakpoint ())
         {
           m_bp_list.append (octave_value (tr.line ()));
           m_bp_cond_list.append (octave_value (tr.bp_cond ()));
         }
+      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.
     }
-  else
-    panic_impossible ();
 }
 
 void
@@ -452,30 +462,34 @@
 {
   int lineno = stmt.line ();
 
-  if (m_action == set)
+  switch (m_action)
     {
+    case set:
       stmt.set_breakpoint (m_condition);
       m_line = lineno;
       m_found = true;
-    }
-  else if (m_action == clear)
-    {
+      break;
+
+    case clear:
       if (stmt.is_breakpoint ())
         {
           stmt.delete_breakpoint ();
           m_found = true;
         }
-    }
-  else if (m_action == list)
-    {
+      break;
+
+    case list:
       if (stmt.is_breakpoint ())
         {
           m_bp_list.append (octave_value (lineno));
           m_bp_cond_list.append (octave_value (stmt.bp_cond ()));
         }
+      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.
     }
-  else
-    panic_impossible ();
 }
 
 OCTAVE_END_NAMESPACE(octave)
--- a/libinterp/parse-tree/pt-eval.cc	Sat Apr 06 17:38:27 2024 -0400
+++ b/libinterp/parse-tree/pt-eval.cc	Sun Apr 07 13:40:32 2024 -0400
@@ -79,6 +79,12 @@
 
 OCTAVE_BEGIN_NAMESPACE(octave)
 
+OCTAVE_NORETURN static void
+error_unexpected (const char *name)
+{
+  error ("unexpected call to %s - please report this bug", name);
+}
+
 // Normal evaluator.
 
 class debugger
@@ -1243,13 +1249,13 @@
 void
 tree_evaluator::visit_anon_fcn_handle (tree_anon_fcn_handle&)
 {
-  panic_impossible ();
+  error_unexpected ("tree_evaluator::visit_anon_fcn_handle");
 }
 
 void
 tree_evaluator::visit_argument_list (tree_argument_list&)
 {
-  panic_impossible ();
+  error_unexpected ("tree_evaluator::visit_argument_list");
 }
 
 void
@@ -1261,49 +1267,49 @@
 void
 tree_evaluator::visit_args_block_attribute_list (tree_args_block_attribute_list&)
 {
-  panic_impossible ();
+  error_unexpected ("tree_evaluator::visit_args_block_attribute_list");
 }
 
 void
 tree_evaluator::visit_args_block_validation_list (tree_args_block_validation_list&)
 {
-  panic_impossible ();
+  error_unexpected ("tree_evaluator::visit_args_block_validation_list");
 }
 
 void
 tree_evaluator::visit_arg_validation (tree_arg_validation&)
 {
-  panic_impossible ();
+  error_unexpected ("tree_evaluator::visit_arg_validation");
 }
 
 void
 tree_evaluator::visit_arg_size_spec (tree_arg_size_spec&)
 {
-  panic_impossible ();
+  error_unexpected ("tree_evaluator::visit_arg_size_spec");
 }
 
 void
 tree_evaluator::visit_arg_validation_fcns (tree_arg_validation_fcns&)
 {
-  panic_impossible ();
+  error_unexpected ("tree_evaluator::visit_arg_validation_fcns");
 }
 
 void
 tree_evaluator::visit_binary_expression (tree_binary_expression&)
 {
-  panic_impossible ();
+  error_unexpected ("tree_evaluator::visit_binary_expression");
 }
 
 void
 tree_evaluator::visit_boolean_expression (tree_boolean_expression&)
 {
-  panic_impossible ();
+  error_unexpected ("tree_evaluator::visit_boolean_expression");
 }
 
 void
 tree_evaluator::visit_compound_binary_expression (tree_compound_binary_expression&)
 {
-  panic_impossible ();
+  error_unexpected ("tree_evaluator::visit_compound_binary_expression");
 }
 
 void
@@ -1330,7 +1336,7 @@
 void
 tree_evaluator::visit_colon_expression (tree_colon_expression&)
 {
-  panic_impossible ();
+  error_unexpected ("tree_evaluator::visit_colon_expression");
 }
 
 void
@@ -3626,7 +3632,7 @@
 tree_evaluator::visit_octave_user_script (octave_user_script&)
 {
   // ??
-  panic_impossible ();
+  error_unexpected ("tree_evaluator::visit_octave_user_script");
 }
 
 octave_value_list
@@ -3809,19 +3815,19 @@
 tree_evaluator::visit_octave_user_function (octave_user_function&)
 {
   // ??
-  panic_impossible ();
+  error_unexpected ("tree_evaluator::visit_octave_user_function");
 }
 
 void
 tree_evaluator::visit_octave_user_function_header (octave_user_function&)
 {
-  panic_impossible ();
+  error_unexpected ("tree_evaluator::visit_octave_user_function_header");
 }
 
 void
 tree_evaluator::visit_octave_user_function_trailer (octave_user_function&)
 {
-  panic_impossible ();
+  error_unexpected ("tree_evaluator::visit_octave_user_function_trailer");
 }
 
 void
@@ -3849,13 +3855,13 @@
 void
 tree_evaluator::visit_identifier (tree_identifier&)
 {
-  panic_impossible ();
+  error_unexpected ("tree_evaluator::visit_identifier");
 }
 
 void
 tree_evaluator::visit_if_clause (tree_if_clause&)
 {
-  panic_impossible ();
+  error_unexpected ("tree_evaluator::visit_if_clause");
 }
 
 void
@@ -3908,25 +3914,25 @@
 void
 tree_evaluator::visit_index_expression (tree_index_expression&)
 {
-  panic_impossible ();
+  error_unexpected ("tree_evaluator::visit_index_expression");
 }
 
 void
 tree_evaluator::visit_matrix (tree_matrix&)
 {
-  panic_impossible ();
+  error_unexpected ("tree_evaluator::visit_matrix");
 }
 
 void
 tree_evaluator::visit_cell (tree_cell&)
 {
-  panic_impossible ();
+  error_unexpected ("tree_evaluator::visit_cell");
 }
 
 void
 tree_evaluator::visit_multi_assignment (tree_multi_assignment&)
 {
-  panic_impossible ();
+  error_unexpected ("tree_evaluator::visit_multi_assignment");
 }
 
 void
@@ -3948,31 +3954,31 @@
 void
 tree_evaluator::visit_constant (tree_constant&)
 {
-  panic_impossible ();
+  error_unexpected ("tree_evaluator::visit_constant");
 }
 
 void
 tree_evaluator::visit_fcn_handle (tree_fcn_handle&)
 {
-  panic_impossible ();
+  error_unexpected ("tree_evaluator::visit_fcn_handle");
 }
 
 void
 tree_evaluator::visit_parameter_list (tree_parameter_list&)
 {
-  panic_impossible ();
+  error_unexpected ("tree_evaluator::visit_parameter_list");
 }
 
 void
 tree_evaluator::visit_postfix_expression (tree_postfix_expression&)
 {
-  panic_impossible ();
+  error_unexpected ("tree_evaluator::visit_postfix_expression");
 }
 
 void
 tree_evaluator::visit_prefix_expression (tree_prefix_expression&)
 {
-  panic_impossible ();
+  error_unexpected ("tree_evaluator::visit_prefix_expression");
 }
 
 void
@@ -4003,7 +4009,7 @@
 void
 tree_evaluator::visit_simple_assignment (tree_simple_assignment&)
 {
-  panic_impossible ();
+  error_unexpected ("tree_evaluator::visit_simple_assignment");
 }
 
 void
@@ -4169,13 +4175,13 @@
 void
 tree_evaluator::visit_switch_case (tree_switch_case&)
 {
-  panic_impossible ();
+  error_unexpected ("tree_evaluator::visit_switch_case");
 }
 
 void
 tree_evaluator::visit_switch_case_list (tree_switch_case_list&)
 {
-  panic_impossible ();
+  error_unexpected ("tree_evaluator::visit_switch_case_list");
 }
 
 void
@@ -4517,13 +4523,13 @@
 void
 tree_evaluator::visit_superclass_ref (tree_superclass_ref&)
 {
-  panic_impossible ();
+  error_unexpected ("tree_evaluator::visit_superclass_ref");
 }
 
 void
 tree_evaluator::visit_metaclass_query (tree_metaclass_query&)
 {
-  panic_impossible ();
+  error_unexpected ("tree_evaluator::visit_metaclass_query");
 }
 
 void