diff options
| author | Manuel López-Ibáñez <manu@gcc.gnu.org> | 2014-12-02 16:03:31 +0000 |
|---|---|---|
| committer | Manuel López-Ibáñez <manu@gcc.gnu.org> | 2014-12-02 16:03:31 +0000 |
| commit | 73bd83290ace3d8e3256103a59d79e6ec3946964 (patch) | |
| tree | 5d0f39e1459edaf29cc238629070efeb1fc76e01 /libcpp/include | |
| parent | 9c320ab1f162ae90a16d99851e7320ad8291e4f4 (diff) | |
| download | gcc-73bd83290ace3d8e3256103a59d79e6ec3946964.tar.gz gcc-73bd83290ace3d8e3256103a59d79e6ec3946964.tar.bz2 gcc-73bd83290ace3d8e3256103a59d79e6ec3946964.zip | |
line-map.h (linemap_assert_fails): Declare.
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.
From-SVN: r218277
Diffstat (limited to 'libcpp/include')
| -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 |
