diff options
| author | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-09-26 03:33:06 +0000 |
|---|---|---|
| committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-09-26 03:33:06 +0000 |
| commit | fde9485297895ac96ece2234021ec72270c703e7 (patch) | |
| tree | 6c439a9ea82da942db8358dc6db731f090c8e262 /clang/test/Lexer | |
| parent | 7d2960bd2a137cbb9ed416e6abcf5acd411562dc (diff) | |
| download | bcm5719-llvm-fde9485297895ac96ece2234021ec72270c703e7.tar.gz bcm5719-llvm-fde9485297895ac96ece2234021ec72270c703e7.zip | |
Implement C++1y digit separator proposal (' as a digit separator). This is not
yet approved by full committee, but was unanimously supported by EWG.
llvm-svn: 191417
Diffstat (limited to 'clang/test/Lexer')
| -rw-r--r-- | clang/test/Lexer/cxx1y_binary_literal.cpp | 1 | ||||
| -rw-r--r-- | clang/test/Lexer/cxx1y_digit_separators.cpp | 34 |
2 files changed, 35 insertions, 0 deletions
diff --git a/clang/test/Lexer/cxx1y_binary_literal.cpp b/clang/test/Lexer/cxx1y_binary_literal.cpp index 96dce3dd443..662e99d28c0 100644 --- a/clang/test/Lexer/cxx1y_binary_literal.cpp +++ b/clang/test/Lexer/cxx1y_binary_literal.cpp @@ -17,3 +17,4 @@ int k1 = 0b1234; // expected-error {{invalid digit '2' in binary constant}} // we'll need to rework our binary literal parsing rules. int k2 = 0b10010f; // expected-error {{invalid digit 'f' in binary constant}} int k3 = 0b10010g; // expected-error {{invalid suffix 'g' on integer constant}} +int k4 = 0b; // expected-error {{invalid digit 'b' in octal constant}} diff --git a/clang/test/Lexer/cxx1y_digit_separators.cpp b/clang/test/Lexer/cxx1y_digit_separators.cpp new file mode 100644 index 00000000000..2c83b1fcdba --- /dev/null +++ b/clang/test/Lexer/cxx1y_digit_separators.cpp @@ -0,0 +1,34 @@ +// RUN: %clang_cc1 -std=c++1y -verify %s + +int operator""ms(unsigned long long); // expected-warning {{reserved}} +float operator""ms(long double); // expected-warning {{reserved}} + +namespace integral { + static_assert(1'2'3 == 12'3, ""); + static_assert(1'000'000 == 0xf'4240, ""); + static_assert(0'004'000'000 == 0x10'0000, ""); + static_assert(0b0101'0100 == 0x54, ""); + + int a = 123'; //'; // expected-error {{expected ';'}} + int b = 0'xff; // expected-error {{digit separator cannot appear at end of digit sequence}} expected-error {{suffix 'xff' on integer}} + int c = 0x'ff; // expected-error {{suffix 'x'ff' on integer}} + int d = 0'1234; // ok, octal + int e = 0'b1010; // expected-error {{digit 'b' in octal constant}} + int f = 0b'1010; // expected-error {{invalid digit 'b' in octal}} + int g = 123'ms; // expected-error {{digit separator cannot appear at end of digit sequence}} + + // FIXME: not yet known if _ after ' will be permitted. + int z = 0'123'_foo; //'; // expected-error {{expected ';'}} +} + +namespace floating { + static_assert(0'123.456'7 == 123.4567, ""); + static_assert(1e1'0 == 10'000'000'000, ""); + + float a = 1'e1; // expected-error {{digit separator cannot appear at end of digit sequence}} + float b = 1'0e1; + float c = 1.'0e1; // expected-error {{digit separator cannot appear at start of digit sequence}} + float d = 1.0'e1; // expected-error {{digit separator cannot appear at end of digit sequence}} + float e = 1e'1; // expected-error {{digit separator cannot appear at start of digit sequence}} + float f = 1e1'ms; // expected-error {{digit separator cannot appear at end of digit sequence}} +} |

