diff options
author | Manuel López-Ibáñez <manu@gcc.gnu.org> | 2009-04-22 15:32:18 +0000 |
---|---|---|
committer | Manuel López-Ibáñez <manu@gcc.gnu.org> | 2009-04-22 15:32:18 +0000 |
commit | cfc935327585254eabd5c18f298b1b4bc28a2b02 (patch) | |
tree | 51e37b610f5f0eae957aa2a3cee06eec9ab65abb /gcc/c-common.c | |
parent | 8632d02a43457ecbcef85175e7575e5da6784646 (diff) | |
download | gcc-cfc935327585254eabd5c18f298b1b4bc28a2b02.zip gcc-cfc935327585254eabd5c18f298b1b4bc28a2b02.tar.gz gcc-cfc935327585254eabd5c18f298b1b4bc28a2b02.tar.bz2 |
re PR c++/14875 (When using 'or' keyword, the error message speaks of a '||' token)
2009-04-22 Manuel Lopez-Ibanez <manu@gcc.gnu.org>
PR c++/14875
* c-common.c (c_parse_error): Take a token_flags parameter.
Use token_type for the token type instead.
Pass token_flags to cpp_type2name.
* c-common.h (c_parse_error): Update declaration.
* c-parser.c (c_parser_error): Pass 0 as token flags.
libcpp/
* lex.c (cpp_type2name): Take a flags parameter. Call
cpp_named_operator2name for named operators and cpp_digraph2name
for digraphs.
(cpp_digraph2name): New.
(cpp_spell_token): Use it.
(cpp_output_token): Likewise.
* include/cpplib.h (cpp_type2name): Update declaration.
* init.c (cpp_named_operator2name): New.
* internal.h (cpp_named_operator2name): Declare.
cp/
* parser.c (cp_parser_error): Pass token->flags to c_parse_error.
testsuite/
* g++.dg/parse/parser-pr14875.C: New.
* g++.dg/parse/parser-pr14875-2.C: New.
* g++.dg/parse/error6.C: Update match string.
From-SVN: r146589
Diffstat (limited to 'gcc/c-common.c')
-rw-r--r-- | gcc/c-common.c | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/gcc/c-common.c b/gcc/c-common.c index 3595e55..67fe8ad 100644 --- a/gcc/c-common.c +++ b/gcc/c-common.c @@ -8167,21 +8167,24 @@ catenate_strings (const char *lhs, const char *rhs_start, int rhs_size) TOKEN, which had the associated VALUE. */ void -c_parse_error (const char *gmsgid, enum cpp_ttype token, tree value) +c_parse_error (const char *gmsgid, enum cpp_ttype token_type, + tree value, unsigned char token_flags) { #define catenate_messages(M1, M2) catenate_strings ((M1), (M2), sizeof (M2)) char *message = NULL; - if (token == CPP_EOF) + if (token_type == CPP_EOF) message = catenate_messages (gmsgid, " at end of input"); - else if (token == CPP_CHAR || token == CPP_WCHAR || token == CPP_CHAR16 - || token == CPP_CHAR32) + else if (token_type == CPP_CHAR + || token_type == CPP_WCHAR + || token_type == CPP_CHAR16 + || token_type == CPP_CHAR32) { unsigned int val = TREE_INT_CST_LOW (value); const char *prefix; - switch (token) + switch (token_type) { default: prefix = ""; @@ -8206,26 +8209,28 @@ c_parse_error (const char *gmsgid, enum cpp_ttype token, tree value) free (message); message = NULL; } - else if (token == CPP_STRING || token == CPP_WSTRING || token == CPP_STRING16 - || token == CPP_STRING32) + else if (token_type == CPP_STRING + || token_type == CPP_WSTRING + || token_type == CPP_STRING16 + || token_type == CPP_STRING32) message = catenate_messages (gmsgid, " before string constant"); - else if (token == CPP_NUMBER) + else if (token_type == CPP_NUMBER) message = catenate_messages (gmsgid, " before numeric constant"); - else if (token == CPP_NAME) + else if (token_type == CPP_NAME) { message = catenate_messages (gmsgid, " before %qE"); error (message, value); free (message); message = NULL; } - else if (token == CPP_PRAGMA) + else if (token_type == CPP_PRAGMA) message = catenate_messages (gmsgid, " before %<#pragma%>"); - else if (token == CPP_PRAGMA_EOL) + else if (token_type == CPP_PRAGMA_EOL) message = catenate_messages (gmsgid, " before end of line"); - else if (token < N_TTYPES) + else if (token_type < N_TTYPES) { message = catenate_messages (gmsgid, " before %qs token"); - error (message, cpp_type2name (token)); + error (message, cpp_type2name (token_type, token_flags)); free (message); message = NULL; } |