Mercurial > octave
changeset 33382:79cfa1b7a813
replace nearly all remaining uses of panic_impossible with error
Affected files: data.cc, error.cc, find.cc, graphics.in.h, ls-hdf5.cc,
oct-hist.cc, oct-stream.cc, pr-output.cc, quad.cc, __init_fltk__.cc,
cdef-class.cc, cdef-utils.cc, ov.h, octave.cc, pt-anon-scopes.cc,
pt-array-list.cc, pt-assign.cc, pt-cmd.h, pt-eval.cc, pt-idx.cc,
pt-stmt.cc, pt-walk.cc, and Sparse.cc.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 12 Apr 2024 11:15:32 -0400 |
parents | 6f7fe3f85253 |
children | e6806f30226a 899b5fb309ee |
files | libinterp/corefcn/data.cc libinterp/corefcn/error.cc libinterp/corefcn/find.cc libinterp/corefcn/graphics.in.h libinterp/corefcn/ls-hdf5.cc libinterp/corefcn/oct-hist.cc libinterp/corefcn/oct-stream.cc libinterp/corefcn/pr-output.cc libinterp/corefcn/quad.cc libinterp/dldfcn/__init_fltk__.cc libinterp/octave-value/cdef-class.cc libinterp/octave-value/cdef-utils.cc libinterp/octave-value/ov.h libinterp/octave.cc libinterp/parse-tree/pt-anon-scopes.cc libinterp/parse-tree/pt-array-list.cc libinterp/parse-tree/pt-assign.cc libinterp/parse-tree/pt-cmd.h libinterp/parse-tree/pt-eval.cc libinterp/parse-tree/pt-idx.cc libinterp/parse-tree/pt-stmt.cc libinterp/parse-tree/pt-walk.cc liboctave/array/Sparse.cc |
diffstat | 23 files changed, 79 insertions(+), 55 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/corefcn/data.cc Fri Apr 12 11:17:04 2024 -0400 +++ b/libinterp/corefcn/data.cc Fri Apr 12 11:15:32 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 11:17:04 2024 -0400 +++ b/libinterp/corefcn/error.cc Fri Apr 12 11:15:32 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 11:17:04 2024 -0400 +++ b/libinterp/corefcn/find.cc Fri Apr 12 11:15:32 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 11:17:04 2024 -0400 +++ b/libinterp/corefcn/graphics.in.h Fri Apr 12 11:15:32 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 11:17:04 2024 -0400 +++ b/libinterp/corefcn/ls-hdf5.cc Fri Apr 12 11:15:32 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 11:17:04 2024 -0400 +++ b/libinterp/corefcn/oct-hist.cc Fri Apr 12 11:15:32 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 11:17:04 2024 -0400 +++ b/libinterp/corefcn/oct-stream.cc Fri Apr 12 11:15:32 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 11:17:04 2024 -0400 +++ b/libinterp/corefcn/pr-output.cc Fri Apr 12 11:15:32 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 11:17:04 2024 -0400 +++ b/libinterp/corefcn/quad.cc Fri Apr 12 11:15:32 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 11:17:04 2024 -0400 +++ b/libinterp/dldfcn/__init_fltk__.cc Fri Apr 12 11:15:32 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 11:17:04 2024 -0400 +++ b/libinterp/octave-value/cdef-class.cc Fri Apr 12 11:15:32 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 11:17:04 2024 -0400 +++ b/libinterp/octave-value/cdef-utils.cc Fri Apr 12 11:15:32 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 11:17:04 2024 -0400 +++ b/libinterp/octave-value/ov.h Fri Apr 12 11:15:32 2024 -0400 @@ -1717,7 +1717,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 <> \ @@ -1784,6 +1789,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 11:17:04 2024 -0400 +++ b/libinterp/octave.cc Fri Apr 12 11:15:32 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 11:17:04 2024 -0400 +++ b/libinterp/parse-tree/pt-anon-scopes.cc Fri Apr 12 11:15:32 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 11:17:04 2024 -0400 +++ b/libinterp/parse-tree/pt-array-list.cc Fri Apr 12 11:15:32 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 11:17:04 2024 -0400 +++ b/libinterp/parse-tree/pt-assign.cc Fri Apr 12 11:15:32 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 11:17:04 2024 -0400 +++ b/libinterp/parse-tree/pt-cmd.h Fri Apr 12 11:15:32 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 11:17:04 2024 -0400 +++ b/libinterp/parse-tree/pt-eval.cc Fri Apr 12 11:15:32 2024 -0400 @@ -3648,7 +3648,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 (); @@ -4426,7 +4426,7 @@ tree_expression *expr = cmd.condition (); if (! expr) - panic_impossible (); + error ("unexpected: while condition is nullptr - please report this bug"); for (;;) { @@ -4469,7 +4469,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 11:17:04 2024 -0400 +++ b/libinterp/parse-tree/pt-idx.cc Fri Apr 12 11:15:32 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 11:17:04 2024 -0400 +++ b/libinterp/parse-tree/pt-stmt.cc Fri Apr 12 11:15:32 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 11:17:04 2024 -0400 +++ b/libinterp/parse-tree/pt-walk.cc Fri Apr 12 11:15:32 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 11:17:04 2024 -0400 +++ b/liboctave/array/Sparse.cc Fri Apr 12 11:15:32 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;