X-Git-Url: http://git.sourceforge.jp/view?a=blobdiff_plain;f=gcc%2Fc-common.c;h=4ba17e0cbd93e3616f05ef665667cf5640e592b0;hb=648298e892dac93092649dbe92a8865adbe51748;hp=acc1e4471c7851f3ea2a3702d96ac29dcc43af55;hpb=40e55fbbd58fe04a45af0335bc0b945cec36c9c9;p=pf3gnuchains%2Fgcc-fork.git diff --git a/gcc/c-common.c b/gcc/c-common.c index acc1e4471c7..4ba17e0cbd9 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"