On 12/15/2015 09:51 AM, David Malcolm wrote:
When issuing diagnostics for _Static_assert, we currently ignore the
location/range of the asserted expression, and instead use the
location/range of the first token within it, which can be
incorrect for compound expressions:

error: expression in static assertion is not constant
    _Static_assert (param > 0, "message");
                    ^~~~~

This patch changes things to use EXPR_LOC_OR_LOC, so we use the
location/range of the expression if it has one, falling back to the old
behavior if it doesn't, giving:

error: expression in static assertion is not constant
    _Static_assert (param > 0, "message");
                    ~~~~~~^~~

Successfully bootstrapped&regrtested on x86_64-pc-linux-gnu

OK for trunk in stage 3?

[a much earlier version of this was posted as part of:
"[PATCH 16/22] C/C++ frontend: use tree ranges in various diagnostics"
   https://gcc.gnu.org/ml/gcc-patches/2015-09/msg00745.html
but this patch bears no resemblence apart from the testcase, due to
changes in representation]

gcc/c/ChangeLog:
        * c-parser.c (c_parser_static_assert_declaration_no_semi): Use the
        expression location, falling back on the first token location,
        rather than always using the latter.

gcc/testsuite/ChangeLog:
        * gcc.dg/diagnostic-range-static-assert.c: New test case.
IMHO, this is a bugfix and thus entirely appropriate at this stage.

OK for the trunk.
Jeff

Reply via email to