[cfe-commits] r173622 - PR15067: Don't assert when a UCN appears in a C90 file.

Jordan Rose jordan_rose at apple.com
Mon Jan 28 09:49:47 PST 2013


On Jan 27, 2013, at 16:04 , Richard Smith <richard at metafoo.co.uk> wrote:

> On Sun, Jan 27, 2013 at 12:12 PM, Jordan Rose <jordan_rose at apple.com> wrote:
> Author: jrose
> Date: Sun Jan 27 14:12:04 2013
> New Revision: 173622
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=173622&view=rev
> Log:
> PR15067: Don't assert when a UCN appears in a C90 file.
> 
> Unfortunately, we can't accept the UCN as an extension because we're
> required to treat it as two tokens for preprocessing purposes.
> 
> Modified:
>     cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
>     cfe/trunk/lib/Lex/Lexer.cpp
>     cfe/trunk/lib/Lex/LiteralSupport.cpp
>     cfe/trunk/test/Lexer/c90.c
> 
> Modified: cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td?rev=173622&r1=173621&r2=173622&view=diff
> ==============================================================================
> --- cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td Sun Jan 27 14:12:04 2013
> @@ -127,6 +127,11 @@ def warn_cxx98_compat_literal_ucn_escape
>  def warn_cxx98_compat_literal_ucn_control_character : Warning<
>    "universal character name referring to a control character "
>    "is incompatible with C++98">, InGroup<CXX98Compat>, DefaultIgnore;
> +def warn_ucn_not_valid_in_c89 : Warning<
> +  "universal character names are only valid in C99 or C++; "
> +  "treating as '\\' followed by identifier">, InGroup<Unicode>;
> +def warn_ucn_not_valid_in_c89_literal : ExtWarn<
> +  "universal character names are only valid in C99 or C++">, InGroup<Unicode>;
> 
> 
>  // Literal
> @@ -165,8 +170,6 @@ def ext_string_too_long : Extension<"str
>    "support">, InGroup<OverlengthStrings>;
>  def err_character_too_large : Error<
>    "character too large for enclosing character literal type">;
> -def warn_ucn_not_valid_in_c89 : ExtWarn<
> -  "unicode escape sequences are only valid in C99 or C++">, InGroup<Unicode>;
>  def warn_cxx98_compat_unicode_literal : Warning<
>    "unicode literals are incompatible with C++98">,
>    InGroup<CXX98Compat>, DefaultIgnore;
> 
> Modified: cfe/trunk/lib/Lex/Lexer.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Lexer.cpp?rev=173622&r1=173621&r2=173622&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Lex/Lexer.cpp (original)
> +++ cfe/trunk/lib/Lex/Lexer.cpp Sun Jan 27 14:12:04 2013
> @@ -2698,8 +2698,6 @@ bool Lexer::isCodeCompletionPoint(const
> 
>  uint32_t Lexer::tryReadUCN(const char *&StartPtr, const char *SlashLoc,
>                             Token *Result) {
> -  assert(LangOpts.CPlusPlus || LangOpts.C99);
> -
>    unsigned CharSize;
>    char Kind = getCharAndSize(StartPtr, CharSize);
> 
> @@ -2711,6 +2709,11 @@ uint32_t Lexer::tryReadUCN(const char *&
>    else
>      return 0;
> 
> +  if (!LangOpts.CPlusPlus && !LangOpts.C99) {
> +    Diag(SlashLoc, diag::warn_ucn_not_valid_in_c89);
> 
> Should there be an isLexingRawMode() test here?

Thanks for the catch! Fixed in r173701.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130128/8913c84c/attachment.html>


More information about the cfe-commits mailing list