Add support for C++14 binary integer literals

Closes #1030.
This commit is contained in:
Zackery Spytz 2019-02-10 15:38:49 -07:00
commit 23d83cd9c1
5 changed files with 68 additions and 0 deletions

View file

@ -162,6 +162,7 @@ CPP_TEST_CASES += \
cpp_nodefault \
cpp_static \
cpp_typedef \
cpp14_binary_integer_literals \
cpp17_nested_namespaces \
cpp17_nspace_nested_namespaces \
cpp17_u8_char_literals \

View file

@ -0,0 +1,31 @@
%module cpp14_binary_integer_literals
// Tests are designed so that code compiles with C++98 compilers
%{
#if __cplusplus >= 201402L
#define CPP14 1
#endif
%}
int b1 = 0b1;
int b2 = 0b10;
long b3 = 0b11l;
unsigned long b4 = 0b100ul;
unsigned long b5 = 0B101UL;
%{
#if defined(CPP14)
int b1 = 0b1;
int b2 = 0b10;
long b3 = 0b11l;
unsigned long b4 = 0b100ul;
unsigned long b5 = 0B101UL;
#else
int b1 = 1;
int b2 = 2;
long b3 = 3;
unsigned long b4 = 4;
unsigned long b5 = 5;
#endif
%}

View file

@ -0,0 +1,16 @@
from cpp14_binary_integer_literals import *
if cvar.b1 != 1:
raise RuntimeError
if cvar.b2 != 2:
raise RuntimeError
if cvar.b3 != 3:
raise RuntimeError
if cvar.b4 != 4:
raise RuntimeError
if cvar.b5 != 5:
raise RuntimeError