Mercurial > octave
annotate libinterp/parse-tree/anon-fcn-validator.cc @ 27919:1891570abac8
update Octave Project Developers copyright for the new year
In files that have the "Octave Project Developers" copyright notice,
update for 2020.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 06 Jan 2020 22:29:51 -0500 |
parents | b442ec6dda5c |
children | bd51beb6205e |
rev | line source |
---|---|
27728
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1 /* |
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2 |
27919
1891570abac8
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
27918
diff
changeset
|
3 Copyright (C) 2019-2020 The Octave Project Developers |
27918
b442ec6dda5c
use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents:
27728
diff
changeset
|
4 |
b442ec6dda5c
use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents:
27728
diff
changeset
|
5 See the file COPYRIGHT.md in the top-level directory of this distribution |
b442ec6dda5c
use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents:
27728
diff
changeset
|
6 or <https://octave.org/COPYRIGHT.html/>. |
b442ec6dda5c
use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents:
27728
diff
changeset
|
7 |
27728
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
8 |
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
9 This file is part of Octave. |
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
10 |
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
11 Octave is free software: you can redistribute it and/or modify it |
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
12 under the terms of the GNU General Public License as published by |
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
13 the Free Software Foundation, either version 3 of the License, or |
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
14 (at your option) any later version. |
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
15 |
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
16 Octave is distributed in the hope that it will be useful, but |
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
17 WITHOUT ANY WARRANTY; without even the implied warranty of |
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
19 GNU General Public License for more details. |
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
20 |
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
21 You should have received a copy of the GNU General Public License |
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
22 along with Octave; see the file COPYING. If not, see |
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
23 <https://www.gnu.org/licenses/>. |
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
24 |
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
25 */ |
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
26 |
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
27 #if defined (HAVE_CONFIG_H) |
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
28 # include "config.h" |
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
29 #endif |
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
30 |
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
31 #include <string> |
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
32 |
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
33 #include "anon-fcn-validator.h" |
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
34 #include "ov.h" |
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
35 #include "pt-all.h" |
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
36 |
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
37 namespace octave |
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
38 { |
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
39 anon_fcn_validator::anon_fcn_validator (tree_parameter_list *, |
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
40 tree_expression *expr) |
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
41 : m_ok (true), m_line (-1), m_column (-1), m_message () |
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
42 { |
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
43 expr->accept (*this); |
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
44 } |
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
45 |
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
46 void anon_fcn_validator::visit_postfix_expression (tree_postfix_expression& expr) |
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
47 { |
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
48 octave_value::unary_op op = expr.op_type (); |
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
49 |
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
50 if (op == octave_value::op_incr || op == octave_value::op_decr) |
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
51 error (expr); |
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
52 else |
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
53 tree_walker::visit_postfix_expression (expr); |
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
54 } |
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
55 |
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
56 void anon_fcn_validator::visit_prefix_expression (tree_prefix_expression& expr) |
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
57 { |
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
58 octave_value::unary_op op = expr.op_type (); |
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
59 |
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
60 if (op == octave_value::op_incr || op == octave_value::op_decr) |
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
61 error (expr); |
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
62 else |
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
63 tree_walker::visit_prefix_expression (expr); |
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
64 } |
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
65 |
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
66 void anon_fcn_validator::visit_multi_assignment (tree_multi_assignment& expr) |
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
67 { |
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
68 error (expr); |
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
69 } |
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
70 |
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
71 void anon_fcn_validator::visit_simple_assignment (tree_simple_assignment& expr) |
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
72 { |
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
73 error (expr); |
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
74 } |
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
75 |
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
76 void anon_fcn_validator::error (tree_expression& expr) |
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
77 { |
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
78 m_ok = false; |
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
79 m_line = expr.line (); |
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
80 m_column = expr.column (); |
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
81 m_message |
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
82 = "invalid use of operator " + expr.oper () + " in anonymous function"; |
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
83 } |
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
84 } |