I was asked to resend with an attached patch instead On Mon, Jan 16, 2012 at 10:44 PM, Eitan Adler <[email protected]> wrote: > Currently clang crashes if it sees a construct like > > double e = 0x.p0; > > The following patch seems fix the crash issue and also issues a diagnostic. > > Index: lib/Lex/LiteralSupport.cpp > =================================================================== > --- lib/Lex/LiteralSupport.cpp (revision 148238) > +++ lib/Lex/LiteralSupport.cpp (working copy) > @@ -538,6 +538,12 @@ > // Handle a hex number like 0x1234. > if ((*s == 'x' || *s == 'X') && (isxdigit(s[1]) || s[1] == '.')) { > s++; > + if (!isxdigit(*s)) { > + PP.Diag(PP.AdvanceToTokenCharacter(TokLoc, s-ThisTokBegin), \ > + diag::err_hexconstant_requires_digits); > + hadError = true; > + return; > + } > radix = 16; > DigitsBegin = s; > s = SkipHexDigits(s); > Index: test/Lexer/hexfloat.cpp > =================================================================== > --- test/Lexer/hexfloat.cpp (revision 148238) > +++ test/Lexer/hexfloat.cpp (working copy) > @@ -1,4 +1,5 @@ > // RUN: %clang_cc1 -fsyntax-only -verify -pedantic %s > // RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify -pedantic %s > float f = 0x1p+1; // expected-warning{{hexadecimal floating constants > are a C99 feature}} > +double e = 0x.p0; //expected-error{{hexadecimal floating constants > require a number}} > > Index: include/clang/Basic/DiagnosticLexKinds.td > =================================================================== > --- include/clang/Basic/DiagnosticLexKinds.td (revision 148238) > +++ include/clang/Basic/DiagnosticLexKinds.td (working copy) > @@ -111,6 +111,8 @@ > def ext_imaginary_constant : Extension<"imaginary constants are an > extension">; > def err_hexconstant_requires_exponent : Error< > "hexadecimal floating constants require an exponent">; > +def err_hexconstant_requires_digits : Error< > + "hexadecimal floating constants require a number">; > def ext_hexconstant_invalid : Extension< > "hexadecimal floating constants are a C99 feature">; > def ext_binary_literal : Extension< > > -- > Eitan Adler
-- Eitan Adler
fix-bug-7910.patch
Description: Binary data
_______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
