diff libinterp/parse-tree/pt-check.cc @ 17249:923ce8b42db2

improve try-catch-statement to save exception to a variable (bug #33217) * oct-parse.in.yy (except_command): Handle exception identifiers. * oct-parse.in.yy, parse.h (octave_base_parser::make_try_command): New arg, ID. * pt-except.cc, pt-except.h (tree_try_catch_command::expr_id): New data member. (tree_command::tree_command): Initialize it. (tree_command::~tree_command): Delete it. (tree_command::identifier): New function. * pt-check.cc (tree_checker::visit_try_catch_command): Check for valid expr_id. * pt-pr-code.cc (tree_print_code::visit_try_catch_command): Print expr_id. * pt-eval.cc (tree_evaluator::visit_try_catch_command): Assign message and identifier to variable. * try.tst: New test. * NEWS: Note change.
author Stefan Mahr <dac922@gmx.de>
date Tue, 13 Aug 2013 19:35:53 +0200
parents 127cccb037bf
children c702371ff6df d63878346099
line wrap: on
line diff
--- a/libinterp/parse-tree/pt-check.cc	Tue Aug 13 19:31:59 2013 -0400
+++ b/libinterp/parse-tree/pt-check.cc	Tue Aug 13 19:35:53 2013 +0200
@@ -499,6 +499,15 @@
 {
   tree_statement_list *try_code = cmd.body ();
 
+  tree_identifier *expr_id = cmd.identifier ();
+
+  if (expr_id)
+    {
+      if (! expr_id->lvalue_ok ())
+        gripe ("invalid lvalue used for identifier in try-catch command",
+               cmd.line ());
+    }
+
   if (try_code)
     try_code->accept (*this);