|
| 1 | +# Copyright 2017 David Malcolm <[email protected]> |
| 2 | +# Copyright 2017 Red Hat, Inc. |
| 3 | +# |
| 4 | +# This is free software: you can redistribute it and/or modify it |
| 5 | +# under the terms of the GNU General Public License as published by |
| 6 | +# the Free Software Foundation, either version 3 of the License, or |
| 7 | +# (at your option) any later version. |
| 8 | +# |
| 9 | +# This program is distributed in the hope that it will be useful, but |
| 10 | +# WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 | +# General Public License for more details. |
| 13 | +# |
| 14 | +# You should have received a copy of the GNU General Public License |
| 15 | +# along with this program. If not, see |
| 16 | +# <http://www.gnu.org/licenses/>. |
| 17 | + |
| 18 | +import sys |
| 19 | + |
| 20 | +import gcc |
| 21 | + |
| 22 | +# Verify that various aspects of gcc.Location work |
| 23 | + |
| 24 | +def on_pass_execution(p, fn): |
| 25 | + if p.name == '*warn_function_return': |
| 26 | + caret = fn.start.offset_column(13) |
| 27 | + start = fn.start.offset_column(9) |
| 28 | + finish = fn.start.offset_column(17) |
| 29 | + compound = gcc.Location(caret, start, finish) |
| 30 | + gcc.inform(compound, "compound location") |
| 31 | + assert compound.caret == caret |
| 32 | + assert compound.start == start |
| 33 | + assert compound.finish == finish |
| 34 | + |
| 35 | +# Wire up our callback: |
| 36 | +gcc.register_callback(gcc.PLUGIN_PASS_EXECUTION, |
| 37 | + on_pass_execution) |
| 38 | + |
0 commit comments