Allow to generate associated constants in the body of C++ structs.

Opt-in since it uses a C++17 feature, but this allow exactly the same usage in
C++ and Rust, which I think is nice.

This also fixes constants of transparent structs in general, since the initial
version of this patch broke a test (associated constants in enums), so I added a
test for that too.
This commit is contained in:
Emilio Cobos Álvarez
2019-02-23 17:24:09 -08:00
parent 9761df66c2
commit 80da1f59aa
49 changed files with 430 additions and 233 deletions
+6 -5
View File
@@ -7,13 +7,14 @@
struct AlignFlags {
uint8_t bits;
};
static const AlignFlags AlignFlags_AUTO = (AlignFlags){ .bits = 0 };
static const AlignFlags AlignFlags_NORMAL = (AlignFlags){ .bits = 1 };
static const AlignFlags AlignFlags_START = (AlignFlags){ .bits = 1 << 1 };
static const AlignFlags AlignFlags_END = (AlignFlags){ .bits = 1 << 2 };
static const AlignFlags AlignFlags_FLEX_START = (AlignFlags){ .bits = 1 << 3 };
static const AlignFlags AlignFlags_NORMAL = (AlignFlags){ .bits = 1 };
extern "C" {
static const AlignFlags AlignFlags_START = (AlignFlags){ .bits = 1 << 1 };
void root(AlignFlags flags);
} // extern "C"