diff options
author | manu <manu@138bc75d-0d04-0410-961f-82ee72b054a4> | 2014-12-02 16:03:31 +0000 |
---|---|---|
committer | manu <manu@138bc75d-0d04-0410-961f-82ee72b054a4> | 2014-12-02 16:03:31 +0000 |
commit | 324da92d45b1b704e39ff8802924f16c2ef6cb3f (patch) | |
tree | 5d0f39e1459edaf29cc238629070efeb1fc76e01 /libcpp/include/line-map.h | |
parent | 351855a5cb5432c9ed4827ec0fe3587dbc0b76a7 (diff) | |
download | gcc-324da92d45b1b704e39ff8802924f16c2ef6cb3f.tar.gz |
libcpp/ChangeLog:
2014-12-02 Manuel López-Ibáñez <manu@gcc.gnu.org>
* include/line-map.h (linemap_assert_fails): Declare.
* line-map.c (linemap_position_for_loc_and_offset): Use it.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@218277 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libcpp/include/line-map.h')
-rw-r--r-- | libcpp/include/line-map.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/libcpp/include/line-map.h b/libcpp/include/line-map.h index edcbdc9bd66..48a5dec31e0 100644 --- a/libcpp/include/line-map.h +++ b/libcpp/include/line-map.h @@ -579,6 +579,16 @@ bool linemap_location_from_macro_expansion_p (const struct line_maps *, if (! (EXPR)) \ abort (); \ } while (0) + +/* Assert that becomes a conditional expression when checking is disabled at + compilation time. Use this for conditions that should not happen but if + they happen, it is better to handle them gracefully rather than crash + randomly later. + Usage: + + if (linemap_assert_fails(EXPR)) handle_error(); */ +#define linemap_assert_fails(EXPR) __extension__ \ + ({linemap_assert (EXPR); false;}) /* Assert that MAP encodes locations of tokens that are not part of the replacement-list of a macro expansion. */ @@ -588,6 +598,7 @@ bool linemap_location_from_macro_expansion_p (const struct line_maps *, #else /* Include EXPR, so that unused variable warnings do not occur. */ #define linemap_assert(EXPR) ((void)(0 && (EXPR))) +#define linemap_assert_fails(EXPR) (! (EXPR)) #define linemap_check_ordinary(LINE_MAP) (LINE_MAP) #endif |