[PATCH] Adjust lazy macro definition

https://gcc.gnu.org/ml/gcc-patches/2018-08/msg01072.html
	libcpp/
	* include/cpplib.h (struct cpp_callbacks): Replace
	user_builtin_macro with user_lazy_macro.
	(struct cpp_macro): add lazy field.
	(enum cpp_builtin_type): Remove BT_FIRST_USER, BT_LAST_USER.
	(cpp_define_lazily): Declare.
	* macro.c (enter_macro_context) Use _cpp_maybe_notify_macro_use.
	(warn_of_redefinition): Use cpp_builtin_macro_p, directly call
	user_lazy_macro hook.
	(_cpp_new_macro): Clear lazy field.
	(cpp_define_lazily): Define.
	(_cpp_notify_macro_use): Adjust lazy definition code.
	(cpp_macro_definition): No need to do lazy definition here.
	* pch.c (write_macdef, save_macros): Likewise.
	gcc/c-family/
	* c-cppbuiltin.c (struct lazy_hex_fp_value_struct): Remove macro
	field.
	(laxy_hex_fp_value_count): Make unsigned.
	(lazy_hex_fp_value): Provided with macro & lazy number.  Directly
	manipulate the macro.
	(builtin_defin_with_hex_fp_value): Adjust callback name, use
	cpp_define_lazily.

From-SVN: r263640
This commit is contained in:
Nathan Sidwell
2018-08-17 23:18:11 +00:00
committed by Nathan Sidwell
parent 6f0821f446
commit 800c0e9877
6 changed files with 95 additions and 83 deletions
+9 -5
View File
@@ -605,8 +605,8 @@ struct cpp_callbacks
/* Callback to identify whether an attribute exists. */
int (*has_attribute) (cpp_reader *);
/* Callback that can change a user builtin into normal macro. */
bool (*user_builtin_macro) (cpp_reader *, cpp_hashnode *);
/* Callback that can change a user lazy into normal macro. */
void (*user_lazy_macro) (cpp_reader *, cpp_macro *, unsigned);
/* Callback to parse SOURCE_DATE_EPOCH from environment. */
time_t (*get_source_date_epoch) (cpp_reader *);
@@ -698,6 +698,9 @@ struct GTY(()) cpp_macro {
/* Number of parameters. */
unsigned short paramc;
/* Non-zero if this is a user-lazy macro, value provided by user. */
unsigned char lazy;
/* The kind of this macro (ISO, trad or assert) */
unsigned kind : 2;
@@ -778,9 +781,7 @@ enum cpp_builtin_type
BT_PRAGMA, /* `_Pragma' operator */
BT_TIMESTAMP, /* `__TIMESTAMP__' */
BT_COUNTER, /* `__COUNTER__' */
BT_HAS_ATTRIBUTE, /* `__has_attribute__(x)' */
BT_FIRST_USER, /* User defined builtin macros. */
BT_LAST_USER = BT_FIRST_USER + 63
BT_HAS_ATTRIBUTE /* `__has_attribute__(x)' */
};
#define CPP_HASHNODE(HNODE) ((cpp_hashnode *) (HNODE))
@@ -1001,6 +1002,9 @@ extern void cpp_assert (cpp_reader *, const char *);
extern void cpp_undef (cpp_reader *, const char *);
extern void cpp_unassert (cpp_reader *, const char *);
/* Mark a node as a lazily defined macro. */
extern void cpp_define_lazily (cpp_reader *, cpp_hashnode *node, unsigned N);
/* Undefine all macros and assertions. */
extern void cpp_undef_all (cpp_reader *);