+2015-09-18 Manuel López-Ibáñez <manu@gcc.gnu.org>
+
+ * c-pragma.c (handle_pragma_diagnostic): Use explicit location
+ when warning.
+ * c-pragma.h (pragma_lex): Add optional loc argument.
+
2015-09-16 Mikhail Maltsev <maltsevm@gmail.com>
* c-format.c (check_format_arg): Adjust to use common block size in all
static void
handle_pragma_diagnostic(cpp_reader *ARG_UNUSED(dummy))
{
- const char *kind_string, *option_string;
- unsigned int option_index;
- enum cpp_ttype token;
- diagnostic_t kind;
tree x;
- struct cl_option_handlers handlers;
-
- token = pragma_lex (&x);
+ location_t loc;
+ enum cpp_ttype token = pragma_lex (&x, &loc);
if (token != CPP_NAME)
- GCC_BAD ("missing [error|warning|ignored] after %<#pragma GCC diagnostic%>");
- kind_string = IDENTIFIER_POINTER (x);
+ {
+ warning_at (loc, OPT_Wpragmas,
+ "missing [error|warning|ignored|push|pop]"
+ " after %<#pragma GCC diagnostic%>");
+ }
+ return;
+
+ diagnostic_t kind;
+ const char *kind_string = IDENTIFIER_POINTER (x);
if (strcmp (kind_string, "error") == 0)
kind = DK_ERROR;
else if (strcmp (kind_string, "warning") == 0)
return;
}
else
- GCC_BAD ("expected [error|warning|ignored|push|pop] after %<#pragma GCC diagnostic%>");
+ {
+ warning_at (loc, OPT_Wpragmas,
+ "expected [error|warning|ignored|push|pop]"
+ " after %<#pragma GCC diagnostic%>");
+ return;
+ }
- token = pragma_lex (&x);
+ token = pragma_lex (&x, &loc);
if (token != CPP_STRING)
- GCC_BAD ("missing option after %<#pragma GCC diagnostic%> kind");
- option_string = TREE_STRING_POINTER (x);
+ {
+ warning_at (loc, OPT_Wpragmas,
+ "missing option after %<#pragma GCC diagnostic%> kind");
+ return;
+ }
+
+ struct cl_option_handlers handlers;
set_default_handlers (&handlers);
+
+ unsigned int option_index;
+ const char *option_string = TREE_STRING_POINTER (x);
for (option_index = 0; option_index < cl_options_count; option_index++)
if (strcmp (cl_options[option_index].opt_text, option_string) == 0)
{
global_dc);
return;
}
- GCC_BAD ("unknown option after %<#pragma GCC diagnostic%> kind");
+ warning_at (loc, OPT_Wpragmas,
+ "unknown option after %<#pragma GCC diagnostic%> kind");
}
/* Parse #pragma GCC target (xxx) to set target specific options. */
extern tree maybe_apply_renaming_pragma (tree, tree);
extern void add_to_renaming_pragma_list (tree, tree);
-extern enum cpp_ttype pragma_lex (tree *);
+extern enum cpp_ttype pragma_lex (tree *, location_t *loc = NULL);
/* Flags for use with c_lex_with_flags. The values here were picked
so that 0 means to translate and join strings. */
+2015-09-18 Manuel López-Ibáñez <manu@gcc.gnu.org>
+
+ * c-parser.c (pragma_lex): Add loc argument.
+
2015-09-15 Marek Polacek <polacek@redhat.com>
PR c/67580
/* The interface the pragma parsers have to the lexer. */
enum cpp_ttype
-pragma_lex (tree *value)
+pragma_lex (tree *value, location_t *loc)
{
c_token *tok = c_parser_peek_token (the_parser);
enum cpp_ttype ret = tok->type;
*value = tok->value;
+ if (loc)
+ *loc = tok->location;
+
if (ret == CPP_PRAGMA_EOL || ret == CPP_EOF)
ret = CPP_EOF;
else
+2015-09-18 Manuel López-Ibáñez <manu@gcc.gnu.org>
+
+ * parser.c (pragma_lex): Add loc argument. Rearrange the code to
+ make it more similar to the C version.
+
2015-09-17 Andrew Sutton <andrew.n.sutton@gmail.com>
Jason Merrill <jason@redhat.com>
/* The interface the pragma parsers have to the lexer. */
enum cpp_ttype
-pragma_lex (tree *value)
+pragma_lex (tree *value, location_t *loc)
{
- cp_token *tok;
- enum cpp_ttype ret;
-
- tok = cp_lexer_peek_token (the_parser->lexer);
+ cp_token *tok = cp_lexer_peek_token (the_parser->lexer);
+ enum cpp_ttype ret = tok->type;
- ret = tok->type;
*value = tok->u.value;
+ if (loc)
+ *loc = tok->location;
if (ret == CPP_PRAGMA_EOL || ret == CPP_EOF)
ret = CPP_EOF;
*value = cp_parser_string_literal (the_parser, false, false);
else
{
- cp_lexer_consume_token (the_parser->lexer);
if (ret == CPP_KEYWORD)
ret = CPP_NAME;
+ cp_lexer_consume_token (the_parser->lexer);
}
return ret;
+2015-09-18 Manuel López-Ibáñez <manu@gcc.gnu.org>
+
+ * gcc.dg/pragma-diag-5.c: New test.
+
2015-09-18 Uros Bizjak <ubizjak@gmail.com>
PR middle-end/67619
--- /dev/null
+/* { dg-do compile } */
+#pragma GCC diagnostic /* { dg-warning "24:missing" "missing" { xfail *-*-* } } */
+
+#pragma GCC diagnostic warn /* { dg-warning "24:expected" } */
+
+#pragma GCC diagnostic ignored "-Wfoo" /* { dg-warning "32:unknown" } */