From e6c7a858b0a51dc3b833a2d7b212e5954d7af126 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Wed, 14 Nov 2007 16:14:50 +0000 Subject: [PATCH] Fix a bug handling hex floats in c90 mode, pointed out by Neil. llvm-svn: 44120 --- clang/Lex/LiteralSupport.cpp | 2 +- clang/test/Lexer/c90.c | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 clang/test/Lexer/c90.c diff --git a/clang/Lex/LiteralSupport.cpp b/clang/Lex/LiteralSupport.cpp index c0027f266cac..21ead21bfece 100644 --- a/clang/Lex/LiteralSupport.cpp +++ b/clang/Lex/LiteralSupport.cpp @@ -224,7 +224,7 @@ NumericLiteralParser(const char *begin, const char *end, } // A binary exponent can appear with or with a '.'. If dotted, the // binary exponent is required. - if (*s == 'p' || *s == 'P') { + if ((*s == 'p' || *s == 'P') && PP.getLangOptions().HexFloats) { s++; saw_exponent = true; if (*s == '+' || *s == '-') s++; // sign diff --git a/clang/test/Lexer/c90.c b/clang/test/Lexer/c90.c new file mode 100644 index 000000000000..84d30467b949 --- /dev/null +++ b/clang/test/Lexer/c90.c @@ -0,0 +1,5 @@ +// RUN: clang -std=c90 -fsyntax-only %s -verify + +enum { cast_hex = (long) ( + 0x0p-1 /* expected-error {{invalid suffix 'p' on integer constant}} */ + ) };