aboutsummaryrefslogtreecommitdiff
path: root/libcpp/lex.c
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/lex.c
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/lex.c')
-rw-r--r--libcpp/lex.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/libcpp/lex.c b/libcpp/lex.c
index fa465be..892cfc4 100644
--- a/libcpp/lex.c
+++ b/libcpp/lex.c
@@ -3725,6 +3725,25 @@ _cpp_aligned_alloc (cpp_reader *pfile, size_t len)
return result;
}
+/* Commit or allocate storage from a buffer. */
+
+void *
+_cpp_commit_buff (cpp_reader *pfile, size_t size)
+{
+ void *ptr = BUFF_FRONT (pfile->a_buff);
+
+ if (pfile->hash_table->alloc_subobject)
+ {
+ void *copy = pfile->hash_table->alloc_subobject (size);
+ memcpy (copy, ptr, size);
+ ptr = copy;
+ }
+ else
+ BUFF_FRONT (pfile->a_buff) += size;
+
+ return ptr;
+}
+
/* Say which field of TOK is in use. */
enum cpp_token_fld_kind