-
Notifications
You must be signed in to change notification settings - Fork 314
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support wider range of expressions in enum discriminants
- Loading branch information
1 parent
ef05231
commit b69a9cf
Showing
6 changed files
with
100 additions
and
30 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
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
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,19 @@ | ||
#include <stdarg.h> | ||
#include <stdbool.h> | ||
#include <stdint.h> | ||
#include <stdlib.h> | ||
|
||
#define FOUR 4 | ||
|
||
enum E { | ||
A = 1, | ||
B = -1, | ||
C = (1 + 2), | ||
D = FOUR, | ||
F = 5, | ||
G = (int8_t)'6', | ||
H = (int8_t)false, | ||
}; | ||
typedef int8_t E; | ||
|
||
void root(const E*); |
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,33 @@ | ||
#include <stdarg.h> | ||
#include <stdbool.h> | ||
#include <stdint.h> | ||
#include <stdlib.h> | ||
|
||
#define FOUR 4 | ||
|
||
enum E | ||
#ifdef __cplusplus | ||
: int8_t | ||
#endif // __cplusplus | ||
{ | ||
A = 1, | ||
B = -1, | ||
C = (1 + 2), | ||
D = FOUR, | ||
F = 5, | ||
G = (int8_t)'6', | ||
H = (int8_t)false, | ||
}; | ||
#ifndef __cplusplus | ||
typedef int8_t E; | ||
#endif // __cplusplus | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif // __cplusplus | ||
|
||
void root(const E*); | ||
|
||
#ifdef __cplusplus | ||
} // extern "C" | ||
#endif // __cplusplus |
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,23 @@ | ||
#include <cstdarg> | ||
#include <cstdint> | ||
#include <cstdlib> | ||
#include <ostream> | ||
#include <new> | ||
|
||
static const int8_t FOUR = 4; | ||
|
||
enum class E : int8_t { | ||
A = 1, | ||
B = -1, | ||
C = (1 + 2), | ||
D = FOUR, | ||
F = 5, | ||
G = (int8_t)'6', | ||
H = (int8_t)false, | ||
}; | ||
|
||
extern "C" { | ||
|
||
void root(const E*); | ||
|
||
} // 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,15 @@ | ||
pub const FOUR: i8 = 4; | ||
|
||
#[repr(i8)] | ||
enum E { | ||
A = 1, | ||
B = -1, | ||
C = 1 + 2, | ||
D = FOUR, | ||
F = (5), | ||
G = '6' as i8, | ||
H = false as i8, | ||
} | ||
|
||
#[no_mangle] | ||
pub extern "C" fn root(_: &E) {} |