aboutsummaryrefslogtreecommitdiff
path: root/libcpp/include
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@acm.org>2018-08-17 16:07:19 +0000
committerNathan Sidwell <nathan@gcc.gnu.org>2018-08-17 16:07:19 +0000
commit10f04917abbc42e3717d33d9b5079aa4f9eb9ac5 (patch)
treed1b399c099142510b8abea59d95c27a5dd4ecf58 /libcpp/include
parentc5d725c0a8da3b2227d119871e881d8a6e1bf600 (diff)
downloadgcc-10f04917abbc42e3717d33d9b5079aa4f9eb9ac5.zip
gcc-10f04917abbc42e3717d33d9b5079aa4f9eb9ac5.tar.gz
gcc-10f04917abbc42e3717d33d9b5079aa4f9eb9ac5.tar.bz2
[PATCH] Macro body is trailing array
https://gcc.gnu.org/ml/gcc-patches/2018-08/msg01037.html * include/cpplib.h (enum cpp_macro_kind): New. (struct cpp_macro): Make body trailing array. Add kind field, delete traditional flag. * internal.h (_cpp_new_macro): Declare. (_cpp_reserve_room): New inline. (_cpp_commit_buf): Declare. (_cpp_create_trad_definition): Return new macro. * lex.c (_cpp_commit_buff): New. * macro.c (macro_real_token_count): Count backwards. (replace_args): Pointer equality not orderedness. (_cpp_save_parameter): Use _cpp_reserve_room. (alloc_expansion_token): Delete. (lex_expansion_token): Return macro pointer. Use _cpp_reserve_room. (create_iso_definition): Allocate macro itself. Adjust for different allocation ordering. (_cpp_new_macro): New. (_cpp_create_definition): Adjust for API changes. * traditional.c (push_replacement_text): Don't set traditional flag. (save_replacement_text): Likewise. (_cpp_create_trad_definition): Allocate macro itself, Adjust for different allocation ordering. From-SVN: r263622
Diffstat (limited to 'libcpp/include')
-rw-r--r--libcpp/include/cpplib.h34
1 files changed, 22 insertions, 12 deletions
diff --git a/libcpp/include/cpplib.h b/libcpp/include/cpplib.h
index 2b3440d..a0d0c53 100644
--- a/libcpp/include/cpplib.h
+++ b/libcpp/include/cpplib.h
@@ -671,6 +671,12 @@ struct cpp_dir
dev_t dev;
};
+/* The kind of the cpp_macro. */
+enum cpp_macro_kind {
+ cmk_macro, /* An ISO macro (token expansion). */
+ cmk_traditional, /* A traditional macro (text expansion). */
+};
+
/* Each macro definition is recorded in a cpp_macro structure.
Variadic macros cannot occur with traditional cpp. */
struct GTY(()) cpp_macro {
@@ -683,15 +689,6 @@ struct GTY(()) cpp_macro {
length ("%h.paramc")))
params;
- /* Replacement tokens (ISO) or replacement text (traditional). See
- comment at top of cpptrad.c for how traditional function-like
- macros are encoded. */
- union cpp_macro_u
- {
- cpp_token * GTY ((tag ("0"), length ("%0.count"))) tokens;
- const unsigned char * GTY ((tag ("1"))) text;
- } GTY ((desc ("%1.traditional"))) exp;
-
/* Definition line number. */
source_location line;
@@ -701,6 +698,9 @@ struct GTY(()) cpp_macro {
/* Number of parameters. */
unsigned short paramc;
+ /* The kind of this macro (ISO, trad or assert) */
+ unsigned kind : 2;
+
/* If a function-like macro. */
unsigned int fun_like : 1;
@@ -713,13 +713,23 @@ struct GTY(()) cpp_macro {
/* Nonzero if it has been expanded or had its existence tested. */
unsigned int used : 1;
- /* Indicate which field of 'exp' is in use. */
- unsigned int traditional : 1;
-
/* Indicate whether the tokens include extra CPP_PASTE tokens at the
end to track invalid redefinitions with consecutive CPP_PASTE
tokens. */
unsigned int extra_tokens : 1;
+
+ /* 1 bits spare (32-bit). 33 on 64-bit target. */
+
+ union cpp_exp_u
+ {
+ /* Trailing array of replacement tokens (ISO), or assertion body value. */
+ cpp_token GTY ((tag ("false"), length ("%1.count"))) tokens[1];
+
+ /* Pointer to replacement text (traditional). See comment at top
+ of cpptrad.c for how traditional function-like macros are
+ encoded. */
+ const unsigned char *GTY ((tag ("true"))) text;
+ } GTY ((desc ("%1.kind == cmk_traditional"))) exp;
};
/* The structure of a node in the hash table. The hash table has