diff options
author | Mark Mitchell <mark@codesourcery.com> | 2003-12-15 06:28:23 +0000 |
---|---|---|
committer | Mark Mitchell <mmitchel@gcc.gnu.org> | 2003-12-15 06:28:23 +0000 |
commit | 4bb8ca281f0fb91d296116d2b7496b216c7c1bb3 (patch) | |
tree | cf0b0628bdaaa8f00ed673d539b8e8c5c1193fa3 /gcc/c-common.c | |
parent | 69f364953465519ced88df15edd1422c4382aecd (diff) | |
download | gcc-4bb8ca281f0fb91d296116d2b7496b216c7c1bb3.zip gcc-4bb8ca281f0fb91d296116d2b7496b216c7c1bb3.tar.gz gcc-4bb8ca281f0fb91d296116d2b7496b216c7c1bb3.tar.bz2 |
re PR c++/10779 (Error cascade for unknown type in function prototype)
* c-common.h (c_parse_error): Declare it.
* c-common.c (c_parse_error): New function.
* c-parse.y (yyerror): Use it.
* parser.c (struct cp_parser): Add in_template_argument_list_p.
(cp_parser_error): Use c_parse_error.
(cp_parser_name_lookup_error): New function.
(cp_parser_new): Initialize it.
(cp_parser_declarator): Add parenthesized_p parameter.
(cp_parser_nested_name_specifier_opt): Use
cp_parser_name_lookup_error.
(cp_parser_parenthesized_expression_list): Improve comments.
(cp_parser_condition): Adjust call to cp_parser_declarator.
(cp_parser_template_parameter): Adjust call to
cp_parser_parameter_declaration.
(cp_parser_template_argument_list): Set
in_template_argument_list_p.
(cp_parser_explicit_instantiation): Adjust call to
cp_parser_declarator.
(cp_parser_simple_type_specifier): Remove unncessary code.
(cp_parser_using_declaration): Use cp_parser_name_lookup_error.
(cp_parser_init_declarator): Handle member function definitions.
(cp_parser_direct_declarator): Adjust call to
cp_parser_declarator.
(cp_parser_type_id): Adjust call to cp_parser_declarator.
(cp_parser_parameter_declaration_list): Avoid backtracking where
possible.
(cp_parser_parameter_declaration): Add parenthesized_p parameter.
(cp_parser_function_definition): Remove.
(cp_parser_member_declaration): Do not backtrack to look for
function definitions.
(cp_parser_exception_declaration): Adjust call to
cp_parser_declarator.
(cp_parser_single_declaration): Handle function definitions via
cp_parser_init_declarator.
(cp_parser_save_member_function_body): New function.
PR c++/10779
PR c++/12160
* g++.dg/parse/error3.C: New test.
* g++.dg/parse/error4.C: Likewise.
* g++.dg/abi/mangle4.C: Tweak error messages.
* g++.dg/lookup/using5.C: Likewise.
* g++.dg/other/error2.C: Likewise.
* g++.dg/parse/typename5.C: Likewise.
* g++.dg/parse/undefined1.C: Likewise.
* g++.dg/template/arg2.C: Likewise.
* g++.dg/template/ttp3.C: Likewise.
* g++.dg/template/type1.C: Likewise.
* g++.old-deja/g++.other/crash32.C: Likewise.
* g++.old-djea/g++.pt/defarg8.C: Likewise.
From-SVN: r74624
Diffstat (limited to 'gcc/c-common.c')
-rw-r--r-- | gcc/c-common.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/gcc/c-common.c b/gcc/c-common.c index acc1e44..4ba17e0 100644 --- a/gcc/c-common.c +++ b/gcc/c-common.c @@ -5893,4 +5893,36 @@ c_decl_uninit (tree t) return false; } +/* Issue the error given by MSGID, indicating that it occurred before + TOKEN, which had the associated VALUE. */ + +void +c_parse_error (const char *msgid, enum cpp_ttype token, tree value) +{ + const char *string = _(msgid); + + if (token == CPP_EOF) + error ("%s at end of input", string); + else if (token == CPP_CHAR || token == CPP_WCHAR) + { + unsigned int val = TREE_INT_CST_LOW (value); + const char *const ell = (token == CPP_CHAR) ? "" : "L"; + if (val <= UCHAR_MAX && ISGRAPH (val)) + error ("%s before %s'%c'", string, ell, val); + else + error ("%s before %s'\\x%x'", string, ell, val); + } + else if (token == CPP_STRING + || token == CPP_WSTRING) + error ("%s before string constant", string); + else if (token == CPP_NUMBER) + error ("%s before numeric constant", string); + else if (token == CPP_NAME) + error ("%s before \"%s\"", string, IDENTIFIER_POINTER (value)); + else if (token < N_TTYPES) + error ("%s before '%s' token", string, cpp_type2name (token)); + else + error ("%s", string); +} + #include "gt-c-common.h" |