Add tests for expressions like (0 << SHIFT) | BOOL

Fixes https://github.com/eqrion/cbindgen/issues/412
This commit is contained in:
Jaseem Abid 2019-12-04 15:16:51 +05:30 committed by Emilio Cobos Álvarez
parent df347d984a
commit e0fe4e4c44
16 changed files with 96 additions and 0 deletions

View File

@ -21,8 +21,16 @@
#define QUOTE '\''
#define SHIFT 3
#define TAB '\t'
#define XBOOL 1
#define XFALSE ((0 << SHIFT) | XBOOL)
#define XTRUE (1 << (SHIFT | XBOOL))
#define ZOM 3.14
typedef struct Foo {

View File

@ -21,8 +21,16 @@
#define QUOTE '\''
#define SHIFT 3
#define TAB '\t'
#define XBOOL 1
#define XFALSE ((0 << SHIFT) | XBOOL)
#define XTRUE (1 << (SHIFT | XBOOL))
#define ZOM 3.14
typedef struct Foo {

View File

@ -5,6 +5,10 @@
#define PREFIX_LEN 42
#define PREFIX_X (42 << 42)
#define PREFIX_Y (PREFIX_X + PREFIX_X)
typedef int32_t PREFIX_NamedLenArray[PREFIX_LEN];
typedef int32_t PREFIX_ValuedLenArray[42];

View File

@ -5,6 +5,10 @@
#define PREFIX_LEN 42
#define PREFIX_X (42 << 42)
#define PREFIX_Y (PREFIX_X + PREFIX_X)
typedef int32_t PREFIX_NamedLenArray[PREFIX_LEN];
typedef int32_t PREFIX_ValuedLenArray[42];

View File

@ -21,8 +21,16 @@
#define QUOTE '\''
#define SHIFT 3
#define TAB '\t'
#define XBOOL 1
#define XFALSE ((0 << SHIFT) | XBOOL)
#define XTRUE (1 << (SHIFT | XBOOL))
#define ZOM 3.14
typedef struct {

View File

@ -21,8 +21,16 @@
#define QUOTE '\''
#define SHIFT 3
#define TAB '\t'
#define XBOOL 1
#define XFALSE ((0 << SHIFT) | XBOOL)
#define XTRUE (1 << (SHIFT | XBOOL))
#define ZOM 3.14
typedef struct {

View File

@ -21,8 +21,16 @@ static const int8_t POS_ONE = 1;
static const uint32_t QUOTE = '\'';
static const int64_t SHIFT = 3;
static const uint32_t TAB = '\t';
static const int64_t XBOOL = 1;
static const int64_t XFALSE = ((0 << SHIFT) | XBOOL);
static const int64_t XTRUE = (1 << (SHIFT | XBOOL));
static const float ZOM = 3.14;
struct Foo {

View File

@ -5,6 +5,10 @@
#define PREFIX_LEN 42
#define PREFIX_X (42 << 42)
#define PREFIX_Y (PREFIX_X + PREFIX_X)
typedef int32_t PREFIX_NamedLenArray[PREFIX_LEN];
typedef int32_t PREFIX_ValuedLenArray[42];

View File

@ -5,6 +5,10 @@
#define PREFIX_LEN 42
#define PREFIX_X (42 << 42)
#define PREFIX_Y (PREFIX_X + PREFIX_X)
typedef int32_t PREFIX_NamedLenArray[PREFIX_LEN];
typedef int32_t PREFIX_ValuedLenArray[42];

View File

@ -5,6 +5,10 @@
static const int32_t PREFIX_LEN = 42;
static const int64_t PREFIX_X = (42 << 42);
static const int64_t PREFIX_Y = (PREFIX_X + PREFIX_X);
using PREFIX_NamedLenArray = int32_t[PREFIX_LEN];
using PREFIX_ValuedLenArray = int32_t[42];

View File

@ -21,8 +21,16 @@
#define QUOTE '\''
#define SHIFT 3
#define TAB '\t'
#define XBOOL 1
#define XFALSE ((0 << SHIFT) | XBOOL)
#define XTRUE (1 << (SHIFT | XBOOL))
#define ZOM 3.14
struct Foo {

View File

@ -21,8 +21,16 @@
#define QUOTE '\''
#define SHIFT 3
#define TAB '\t'
#define XBOOL 1
#define XFALSE ((0 << SHIFT) | XBOOL)
#define XTRUE (1 << (SHIFT | XBOOL))
#define ZOM 3.14
struct Foo {

View File

@ -5,6 +5,10 @@
#define PREFIX_LEN 42
#define PREFIX_X (42 << 42)
#define PREFIX_Y (PREFIX_X + PREFIX_X)
typedef int32_t PREFIX_NamedLenArray[PREFIX_LEN];
typedef int32_t PREFIX_ValuedLenArray[42];

View File

@ -5,6 +5,10 @@
#define PREFIX_LEN 42
#define PREFIX_X (42 << 42)
#define PREFIX_Y (PREFIX_X + PREFIX_X)
typedef int32_t PREFIX_NamedLenArray[PREFIX_LEN];
typedef int32_t PREFIX_ValuedLenArray[42];

View File

@ -15,6 +15,12 @@ const DONT_EXPORT_PRIV: i32 = 30;
pub const POS_ONE: i8 = 1;
pub const NEG_ONE: i8 = -1;
// Some doc for shifting //
pub const SHIFT: i64 = 3;
pub const XBOOL: i64 = 1;
pub const XFALSE: i64 = (0 << SHIFT) | XBOOL;
pub const XTRUE: i64 = 1 << (SHIFT | XBOOL);
#[repr(C)]
struct Foo {
x: [i32; FOO],

View File

@ -12,3 +12,9 @@ pub enum AbsoluteFontWeight {
#[no_mangle]
pub extern "C" fn root(x: NamedLenArray, y: ValuedLenArray, z: AbsoluteFontWeight) { }
#[no_mangle]
pub const X: i64 = 42 << 42;
#[no_mangle]
pub const Y: i64 = X + X;