-
Notifications
You must be signed in to change notification settings - Fork 315
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for nested struct literals
- Loading branch information
Showing
6 changed files
with
93 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#include <stdint.h> | ||
#include <stdlib.h> | ||
#include <stdbool.h> | ||
|
||
typedef struct PREFIXBar { | ||
int32_t a; | ||
} PREFIXBar; | ||
|
||
typedef struct PREFIXFoo { | ||
int32_t a; | ||
uint32_t b; | ||
PREFIXBar bar; | ||
} PREFIXFoo; | ||
|
||
#define PREFIXVAL (PREFIXFoo){ .a = 42, .b = 1337, .bar = (PREFIXBar){ .a = 323 } } | ||
|
||
void root(PREFIXFoo x); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#include <stdint.h> | ||
#include <stdlib.h> | ||
#include <stdbool.h> | ||
|
||
typedef struct { | ||
int32_t a; | ||
} PREFIXBar; | ||
|
||
typedef struct { | ||
int32_t a; | ||
uint32_t b; | ||
PREFIXBar bar; | ||
} PREFIXFoo; | ||
|
||
#define PREFIXVAL (PREFIXFoo){ .a = 42, .b = 1337, .bar = (PREFIXBar){ .a = 323 } } | ||
|
||
void root(PREFIXFoo x); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#include <cstdint> | ||
#include <cstdlib> | ||
|
||
struct PREFIXBar { | ||
int32_t a; | ||
}; | ||
|
||
struct PREFIXFoo { | ||
int32_t a; | ||
uint32_t b; | ||
PREFIXBar bar; | ||
}; | ||
|
||
static const PREFIXFoo PREFIXVAL = (PREFIXFoo){ .a = 42, .b = 1337, .bar = (PREFIXBar){ .a = 323 } }; | ||
|
||
extern "C" { | ||
|
||
void root(PREFIXFoo x); | ||
|
||
} // extern "C" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#include <stdint.h> | ||
#include <stdlib.h> | ||
#include <stdbool.h> | ||
|
||
struct PREFIXBar { | ||
int32_t a; | ||
}; | ||
|
||
struct PREFIXFoo { | ||
int32_t a; | ||
uint32_t b; | ||
struct PREFIXBar bar; | ||
}; | ||
|
||
#define PREFIXVAL (PREFIXFoo){ .a = 42, .b = 1337, .bar = (PREFIXBar){ .a = 323 } } | ||
|
||
void root(struct PREFIXFoo x); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#[repr(C)] | ||
struct Foo { | ||
a: i32, | ||
b: u32, | ||
bar: Bar, | ||
} | ||
|
||
#[repr(C)] | ||
struct Bar { | ||
a: i32, | ||
} | ||
|
||
const VAL: Foo = Foo { | ||
a: 42, | ||
b: 1337, | ||
bar: Bar { a: 323 }, | ||
}; | ||
|
||
#[no_mangle] | ||
pub extern "C" fn root(x: Foo) {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[export] | ||
prefix = "PREFIX" |