aboutsummaryrefslogtreecommitdiffstats
path: root/internal
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2023-10-13 03:33:48 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2023-10-14 11:08:43 +0900
commitcb06b6632a0d6e33522d75cab7836ff457a452b5 (patch)
tree3c6a4bdc75ef756b6c392b3e4d7e3f10ac898675 /internal
parent82c8f22a36bfcb04c6ebd422b9201d5487bc4ba4 (diff)
downloadruby-cb06b6632a0d6e33522d75cab7836ff457a452b5.tar.gz
Remove unions in `rb_strterm` structs for alignment
Diffstat (limited to 'internal')
-rw-r--r--internal/parse.h38
1 files changed, 7 insertions, 31 deletions
diff --git a/internal/parse.h b/internal/parse.h
index ce99556ef9..2fcbb24fc1 100644
--- a/internal/parse.h
+++ b/internal/parse.h
@@ -22,48 +22,24 @@ struct rb_iseq_struct; /* in vm_core.h */
/* structs for managing terminator of string literal and heredocment */
typedef struct rb_strterm_literal_struct {
- union {
- VALUE dummy;
- long nest;
- } u0;
- union {
- VALUE dummy;
- long func; /* STR_FUNC_* (e.g., STR_FUNC_ESCAPE and STR_FUNC_EXPAND) */
- } u1;
- union {
- VALUE dummy;
- long paren; /* '(' of `%q(...)` */
- } u2;
- union {
- VALUE dummy;
- long term; /* ')' of `%q(...)` */
- } u3;
+ long nest;
+ long func; /* STR_FUNC_* (e.g., STR_FUNC_ESCAPE and STR_FUNC_EXPAND) */
+ long paren; /* '(' of `%q(...)` */
+ long term; /* ')' of `%q(...)` */
} rb_strterm_literal_t;
-#define HERETERM_LENGTH_BITS ((SIZEOF_VALUE - 1) * CHAR_BIT - 1)
-
typedef struct rb_strterm_heredoc_struct {
VALUE lastline; /* the string of line that contains `<<"END"` */
long offset; /* the column of END in `<<"END"` */
int sourceline; /* lineno of the line that contains `<<"END"` */
- unsigned length /* the length of END in `<<"END"` */
-#if HERETERM_LENGTH_BITS < SIZEOF_INT * CHAR_BIT
- : HERETERM_LENGTH_BITS
-# define HERETERM_LENGTH_MAX ((1U << HERETERM_LENGTH_BITS) - 1)
-#else
-# define HERETERM_LENGTH_MAX UINT_MAX
-#endif
- ;
-#if HERETERM_LENGTH_BITS < SIZEOF_INT * CHAR_BIT
- unsigned quote: 1;
- unsigned func: 8;
-#else
+ unsigned length; /* the length of END in `<<"END"` */
uint8_t quote;
uint8_t func;
-#endif
} rb_strterm_heredoc_t;
STATIC_ASSERT(rb_strterm_heredoc_t, sizeof(rb_strterm_heredoc_t) <= 4 * SIZEOF_VALUE);
+#define HERETERM_LENGTH_MAX UINT_MAX
+
typedef struct rb_strterm_struct {
VALUE flags;
union {