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 | |
| 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')
| -rw-r--r-- | clang/test/Lexer/cxx1y_binary_literal.cpp | 1 | ||||
| -rw-r--r-- | clang/test/Lexer/cxx1y_digit_separators.cpp | 34 | ||||
| -rw-r--r-- | clang/test/SemaCXX/cxx98-compat.cpp | 9 |
3 files changed, 39 insertions, 5 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}} +} diff --git a/clang/test/SemaCXX/cxx98-compat.cpp b/clang/test/SemaCXX/cxx98-compat.cpp index eeef1364af1..9690638ce02 100644 --- a/clang/test/SemaCXX/cxx98-compat.cpp +++ b/clang/test/SemaCXX/cxx98-compat.cpp @@ -1,8 +1,5 @@ // RUN: %clang_cc1 -fsyntax-only -std=c++11 -Wc++98-compat -verify %s -// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -// RUN: %clang_cc1 -fsyntax-only -std=c++1y -Wc++98-c++11-compat -verify %s -DCXX1YCOMPAT - -#ifndef CXX1YCOMPAT +// RUN: %clang_cc1 -fsyntax-only -std=c++1y -Wc++98-compat -verify %s -DCXX1YCOMPAT namespace std { struct type_info; @@ -381,7 +378,6 @@ namespace rdar11736429 { X x; // expected-warning{{union member 'x' with a non-trivial constructor is incompatible with C++98}} }; } -#endif template<typename T> T var = T(10); #ifdef CXX1YCOMPAT @@ -455,3 +451,6 @@ template<> int B::v<int> = 10; template int B::v<int>; float fsvar = B::v<float>; +#ifdef CXX1YCOMPAT +int digit_seps = 123'456; // expected-warning {{digit separators are incompatible with C++ standards before C++1y}} +#endif |

