[cfe-dev] Unknown hex escapes
Paul Curtis
plc at rowley.co.uk
Thu Dec 2 06:59:57 PST 2010
...ok, moving this to cfe-commits...
> -----Original Message-----
> From: cfe-dev-bounces at cs.uiuc.edu [mailto:cfe-dev-bounces at cs.uiuc.edu]
> On Behalf Of Paul Curtis
> Sent: 02 December 2010 14:49
> To: cfe-dev at cs.uiuc.edu
> Subject: [cfe-dev] Unknown hex escapes
>
> Hi,
>
> Given:
>
> const char *format = "abc \m def";
>
> clang generates:
>
> > clang -fsyntax-only foo1.c
> foo1.c(1) : warning: unknown escape sequence '\x6D'
> const char *format = "abc \m def";
> ^
>
> There are a couple of problems here. Firstly, the error should clearly
> show \m not \x6D and ProcessCharEscape makes a valiant attempt:
>
> if (isgraph(ThisTokBuf[0]))
> Diags->Report(Loc, diag::ext_unknown_escape)
> << std::string()+(char)ResultChar;
> else
> Diags->Report(Loc, diag::ext_unknown_escape)
> << "x"+llvm::utohexstr(ResultChar);
>
> Unfortunately, by the time we're in the handling case, ThisTokBuf[0]
> has stepped past the invalid escape and moved to the next character,
> and as witness you get a slightly different error with this source:
>
> > clang -fsyntax-only foo1.c
> foo1.c(1) : warning: unknown escape sequence '\m'
> const char *format = "abc \mx def";
>
> Now, this is correct. What ProcessCharEscape should be doing is this:
>
> if (isgraph(ResultChar))
> Diags->Report(Loc, diag::ext_unknown_escape)
> << std::string()+(char)ResultChar;
> else
> Diags->Report(Loc, diag::ext_unknown_escape)
> << "x"+llvm::utohexstr(ResultChar);
>
> However the location of the caret is incorrect; perhaps I'll deal with
> that next.
>
> --
> Paul Curtis, Rowley Associates Ltd http://www.rowley.co.uk
> SolderCore arriving Winter 2010! http://www.soldercore.com
>
>
>
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
More information about the cfe-dev
mailing list