summaryrefslogtreecommitdiffstats
path: root/clang/test
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2012-06-15 05:07:49 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2012-06-15 05:07:49 +0000
commite6799ddae83082a494f968cab205ef8754f82e64 (patch)
treeec4a93ecceec7ccc243d9ab103f8f912cb651396 /clang/test
parent261a941a12137c64b89648402f5064284c71ac2a (diff)
downloadbcm5719-llvm-e6799ddae83082a494f968cab205ef8754f82e64.tar.gz
bcm5719-llvm-e6799ddae83082a494f968cab205ef8754f82e64.zip
PR12717: Clang supports hexadecimal floating-point literals in all language
modes. For languages other than C99/C11, this isn't quite a conforming extension, and for C++11, it breaks some reasonable code containing user-defined literals. In languages which don't officially have hexfloats, pare back this extension to only apply in cases where the token starts 0x and does not contain an underscore. The extension is still not quite conforming, but it's a lot closer now. llvm-svn: 158487
Diffstat (limited to 'clang/test')
-rw-r--r--clang/test/Lexer/c90.c7
-rw-r--r--clang/test/Lexer/hexfloat.cpp8
2 files changed, 15 insertions, 0 deletions
diff --git a/clang/test/Lexer/c90.c b/clang/test/Lexer/c90.c
index d91057257df..7142c09ac48 100644
--- a/clang/test/Lexer/c90.c
+++ b/clang/test/Lexer/c90.c
@@ -32,3 +32,10 @@ void test3() {
(void)L"\u1234"; // expected-error {{unicode escape sequences are only valid in C99 or C++}}
(void)L'\u1234'; // expected-error {{unicode escape sequences are only valid in C99 or C++}}
}
+
+#define PREFIX(x) foo ## x
+int test4() {
+ int PREFIX(0p) = 0;
+ int *p = &PREFIX(0p+1);
+ return p[-1];
+}
diff --git a/clang/test/Lexer/hexfloat.cpp b/clang/test/Lexer/hexfloat.cpp
index 656693399fa..9bd8f830f03 100644
--- a/clang/test/Lexer/hexfloat.cpp
+++ b/clang/test/Lexer/hexfloat.cpp
@@ -5,3 +5,11 @@ double e = 0x.p0; //expected-error{{hexadecimal floating constants require a sig
double d = 0x.2p2; // expected-warning{{hexadecimal floating constants are a C99 feature}}
float g = 0x1.2p2; // expected-warning{{hexadecimal floating constants are a C99 feature}}
double h = 0x1.p2; // expected-warning{{hexadecimal floating constants are a C99 feature}}
+
+// PR12717: In order to minimally diverge from the C++ standard, we do not lex
+// 'p[+-]' as part of a pp-number unless the token starts 0x and doesn't contain
+// an underscore.
+double i = 0p+3; // expected-error{{invalid suffix 'p' on integer constant}}
+#define PREFIX(x) foo ## x
+double foo0p = 1, j = PREFIX(0p+3); // ok
+double k = 0x42_amp+3; // expected-error-re{{invalid suffix '_amp' on integer constant|no matching literal operator for call to 'operator "" _amp'}}
OpenPOWER on IntegriCloud