+2015-12-16 David Malcolm <dmalcolm@redhat.com>
+
+ * 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.
+
2015-12-16 Marek Polacek <polacek@redhat.com>
PR c/64637
c_parser_consume_token (parser);
if (!c_parser_require (parser, CPP_OPEN_PAREN, "expected %<(%>"))
return;
- value_loc = c_parser_peek_token (parser)->location;
+ location_t value_tok_loc = c_parser_peek_token (parser)->location;
value = c_parser_expr_no_commas (parser, NULL).value;
+ value_loc = EXPR_LOC_OR_LOC (value, value_tok_loc);
parser->lex_untranslated_string = true;
if (!c_parser_require (parser, CPP_COMMA, "expected %<,%>"))
{
+2015-12-16 David Malcolm <dmalcolm@redhat.com>
+
+ * gcc.dg/diagnostic-range-static-assert.c: New test case.
+
2015-12-16 Marek Polacek <polacek@redhat.com>
PR c/64637
--- /dev/null
+/* { dg-options "-fdiagnostics-show-caret" } */
+
+void test_nonconst_static_assert (int param)
+{
+ int local = 0;
+
+ _Static_assert (param > 0, "message"); /* { dg-error "expression in static assertion is not constant" } */
+/* { dg-begin-multiline-output "" }
+ _Static_assert (param > 0, "message");
+ ~~~~~~^~~
+{ dg-end-multiline-output "" } */
+
+ _Static_assert (param, "message"); /* { dg-error "expression in static assertion is not constant" } */
+/* { dg-begin-multiline-output "" }
+ _Static_assert (param, "message");
+ ^~~~~
+{ dg-end-multiline-output "" } */
+
+ _Static_assert (local, "message"); /* { dg-error "expression in static assertion is not constant" } */
+/* { dg-begin-multiline-output "" }
+ _Static_assert (local, "message");
+ ^~~~~
+{ dg-end-multiline-output "" } */
+}