From 55d08b039b9683eedd89e2dee17bc2a347057633 Mon Sep 17 00:00:00 2001 From: Xavier Leroy Date: Sun, 21 Sep 2014 10:35:22 +0200 Subject: Error instead of warning on illegal escape sequences. The previous behavior for illegal escape sequences (e.g. '\%') in character and string literals was to emit an error, then treat "\x" as "x". As reported by a user, this is dangerous, because the warning can go unnoticed, and other compilers can treat "\x" as "\\x" (backslash followed by 'x'). Better to error out. --- cparser/Lexer.mll | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cparser/Lexer.mll') diff --git a/cparser/Lexer.mll b/cparser/Lexer.mll index 276aead2..53a27d81 100644 --- a/cparser/Lexer.mll +++ b/cparser/Lexer.mll @@ -356,7 +356,7 @@ and char = parse | simple_escape_sequence { convert_escape c } | '\\' (_ as c) - { warning lexbuf "incorrect escape sequence '\\%c', treating as '%c'" c c; + { error lexbuf "incorrect escape sequence '\\%c'" c; Int64.of_int (Char.code c) } | _ as c { Int64.of_int (Char.code c) } -- cgit