On Sun, Jan 27, 2013 at 12:12 PM, Jordan Rose <span dir="ltr"><<a href="mailto:jordan_rose@apple.com" target="_blank">jordan_rose@apple.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Author: jrose<br>
Date: Sun Jan 27 14:12:04 2013<br>
New Revision: 173622<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=173622&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=173622&view=rev</a><br>
Log:<br>
PR15067: Don't assert when a UCN appears in a C90 file.<br>
<br>
Unfortunately, we can't accept the UCN as an extension because we're<br>
required to treat it as two tokens for preprocessing purposes.<br>
<br>
Modified:<br>
cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td<br>
cfe/trunk/lib/Lex/Lexer.cpp<br>
cfe/trunk/lib/Lex/LiteralSupport.cpp<br>
cfe/trunk/test/Lexer/c90.c<br>
<br>
Modified: cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td?rev=173622&r1=173621&r2=173622&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td?rev=173622&r1=173621&r2=173622&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td (original)<br>
+++ cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td Sun Jan 27 14:12:04 2013<br>
@@ -127,6 +127,11 @@ def warn_cxx98_compat_literal_ucn_escape<br>
def warn_cxx98_compat_literal_ucn_control_character : Warning<<br>
"universal character name referring to a control character "<br>
"is incompatible with C++98">, InGroup<CXX98Compat>, DefaultIgnore;<br>
+def warn_ucn_not_valid_in_c89 : Warning<<br>
+ "universal character names are only valid in C99 or C++; "<br>
+ "treating as '\\' followed by identifier">, InGroup<Unicode>;<br>
+def warn_ucn_not_valid_in_c89_literal : ExtWarn<<br>
+ "universal character names are only valid in C99 or C++">, InGroup<Unicode>;<br>
<br>
<br>
// Literal<br>
@@ -165,8 +170,6 @@ def ext_string_too_long : Extension<"str<br>
"support">, InGroup<OverlengthStrings>;<br>
def err_character_too_large : Error<<br>
"character too large for enclosing character literal type">;<br>
-def warn_ucn_not_valid_in_c89 : ExtWarn<<br>
- "unicode escape sequences are only valid in C99 or C++">, InGroup<Unicode>;<br>
def warn_cxx98_compat_unicode_literal : Warning<<br>
"unicode literals are incompatible with C++98">,<br>
InGroup<CXX98Compat>, DefaultIgnore;<br>
<br>
Modified: cfe/trunk/lib/Lex/Lexer.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Lexer.cpp?rev=173622&r1=173621&r2=173622&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Lexer.cpp?rev=173622&r1=173621&r2=173622&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Lex/Lexer.cpp (original)<br>
+++ cfe/trunk/lib/Lex/Lexer.cpp Sun Jan 27 14:12:04 2013<br>
@@ -2698,8 +2698,6 @@ bool Lexer::isCodeCompletionPoint(const<br>
<br>
uint32_t Lexer::tryReadUCN(const char *&StartPtr, const char *SlashLoc,<br>
Token *Result) {<br>
- assert(LangOpts.CPlusPlus || LangOpts.C99);<br>
-<br>
unsigned CharSize;<br>
char Kind = getCharAndSize(StartPtr, CharSize);<br>
<br>
@@ -2711,6 +2709,11 @@ uint32_t Lexer::tryReadUCN(const char *&<br>
else<br>
return 0;<br>
<br>
+ if (!LangOpts.CPlusPlus && !LangOpts.C99) {<br>
+ Diag(SlashLoc, diag::warn_ucn_not_valid_in_c89);<br></blockquote><div><br></div><div>Should there be an isLexingRawMode() test here?</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ return 0;<br>
+ }<br>
+<br>
const char *CurPtr = StartPtr + CharSize;<br>
const char *KindLoc = &CurPtr[-1];<br>
<br>
@@ -2737,7 +2740,7 @@ uint32_t Lexer::tryReadUCN(const char *&<br>
}<br>
}<br>
}<br>
-<br>
+<br>
return 0;<br>
}<br>
<br>
<br>
Modified: cfe/trunk/lib/Lex/LiteralSupport.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/LiteralSupport.cpp?rev=173622&r1=173621&r2=173622&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/LiteralSupport.cpp?rev=173622&r1=173621&r2=173622&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Lex/LiteralSupport.cpp (original)<br>
+++ cfe/trunk/lib/Lex/LiteralSupport.cpp Sun Jan 27 14:12:04 2013<br>
@@ -277,7 +277,7 @@ static bool ProcessUCNEscape(const char<br>
<br>
if (!Features.CPlusPlus && !Features.C99 && Diags)<br>
Diag(Diags, Features, Loc, ThisTokBegin, UcnBegin, ThisTokBuf,<br>
- diag::warn_ucn_not_valid_in_c89);<br>
+ diag::warn_ucn_not_valid_in_c89_literal);<br>
<br>
return true;<br>
}<br>
<br>
Modified: cfe/trunk/test/Lexer/c90.c<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/c90.c?rev=173622&r1=173621&r2=173622&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/c90.c?rev=173622&r1=173621&r2=173622&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/Lexer/c90.c (original)<br>
+++ cfe/trunk/test/Lexer/c90.c Sun Jan 27 14:12:04 2013<br>
@@ -29,8 +29,8 @@ void test2() {<br>
}<br>
<br>
void test3() {<br>
- (void)L"\u1234"; // expected-error {{unicode escape sequences are only valid in C99 or C++}}<br>
- (void)L'\u1234'; // expected-error {{unicode escape sequences are only valid in C99 or C++}}<br>
+ (void)L"\u1234"; // expected-error {{universal character names are only valid in C99 or C++}}<br>
+ (void)L'\u1234'; // expected-error {{universal character names are only valid in C99 or C++}}<br>
}<br>
<br>
#define PREFIX(x) foo ## x<br>
@@ -39,3 +39,5 @@ int test4() {<br>
int *p = &PREFIX(0p+1);<br>
return p[-1];<br>
}<br>
+<br>
+#define MY_UCN \u00FC // expected-warning {{universal character names are only valid in C99 or C++; treating as '\' followed by identifier}}<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br>