# HG changeset patch # User John W. Eaton # Date 1592929890 14400 # Tue Jun 23 12:31:30 2020 -0400 # Node ID 16b4e0bd7a803f9f4bf298e9d69db4fbdcf0a460 # Parent 7a640885171ad8b1b6e14b56142f78bc9203f64b save warning info for disabled warnings (bug #41028) * error.cc (error_system::vwarning (char *name, const char *, const char *, va_list)): Check warning state here. Save warning info for disabled warnings but don't display them. (error_system::vwarning (const char *, const char *, va_list args)): Don't check warning state here. Just call vwarning ("warning", ...). diff --git a/libinterp/corefcn/error.cc b/libinterp/corefcn/error.cc --- a/libinterp/corefcn/error.cc +++ b/libinterp/corefcn/error.cc @@ -519,7 +519,15 @@ namespace octave void error_system::vwarning (const char *name, const char *id, const char *fmt, va_list args) { - flush_stdout (); + int warn_opt = warning_enabled (id); + + if (warn_opt == 2) + { + // Handle this warning as an error. ERROR_1 won't return. + + error_1 (id, fmt, args); + } + std::string base_msg = format_message (fmt, args); std::string msg_string; @@ -539,13 +547,18 @@ namespace octave last_warning_id (id); last_warning_message (base_msg); - if (discard_warning_messages ()) + // If WARN_OPT is 0, then the warning is disabled. But we sill + // still set LAST_WARNING_MESSAGE above. + + if (discard_warning_messages () || warn_opt == 0) return; tree_evaluator& tw = m_interpreter.get_evaluator (); bool in_user_code = tw.in_user_code (); + flush_stdout (); + if (! quiet_warning ()) { octave_diary << msg_string; @@ -601,16 +614,13 @@ namespace octave void error_system::vwarning (const char *id, const char *fmt, va_list args) { - int warn_opt = warning_enabled (id); + // OK, this probably seems strange now, but there is a version of + // vwarning that takes the "name" of the warning as an argument, + // possibly because "usage" was previously handled as a warning? + // For consistent behavior, that function will deal with all the the + // ON/OFF/ERROR warning state options. - if (warn_opt == 2) - { - // Handle this warning as an error. - - error_1 (id, fmt, args); - } - else if (warn_opt == 1) - vwarning ("warning", id, fmt, args); + vwarning ("warning", id, fmt, args); } void error_system::rethrow_error (const std::string& id,