c_register_pragma:
/* Register a C pragma handler, using a space and a name. It disallows pragma expansion (if you want it, use c_register_pragma_with_expansion instead). */ void c_register_pragma (const char *space, const char *name, pragma_handler_1arg handler) { internal_pragma_handler ihandler;
ihandler.handler.handler_1arg = handler; ihandler.extra_data = false; ihandler.data = NULL; c_register_pragma_1 (space, name, ihandler, false); }
/* Front-end wrappers for pragma registration. */ typedef void (*pragma_handler_1arg)(struct cpp_reader *); /* A second pragma handler, which adds a void * argument allowing to pass extra data to the handler. */ typedef void (*pragma_handler_2arg)(struct cpp_reader *, void *);
/* This union allows to abstract the different handlers. */ union gen_pragma_handler { pragma_handler_1arg handler_1arg; pragma_handler_2arg handler_2arg; }; /* Internally used to keep the data of the handler. */ struct internal_pragma_handler { union gen_pragma_handler handler; /* Permits to know if handler is a pragma_handler_1arg (extra_data is false) or a pragma_handler_2arg (extra_data is true). */ bool extra_data; /* A data field which can be used when extra_data is true. */ void * data; };
/* Front-end wrappers for pragma registration to avoid dragging cpplib.h in almost everywhere. */
static void c_register_pragma_1 (const char *space, const char *name, internal_pragma_handler ihandler, bool allow_expansion) { unsigned id;
if (flag_preprocess_only) { pragma_ns_name ns_name;
if (!allow_expansion) return;
ns_name.space = space; ns_name.name = name; registered_pp_pragmas.safe_push (ns_name); id = registered_pp_pragmas.length (); id += PRAGMA_FIRST_EXTERNAL - 1; } else { registered_pragmas.safe_push (ihandler); id = registered_pragmas.length (); id += PRAGMA_FIRST_EXTERNAL - 1;
/* The C front end allocates 8 bits in c_token. The C++ front end keeps the pragma kind in the form of INTEGER_CST, so no small limit applies. At present this is sufficient. */ gcc_assert (id < 256); }
cpp_register_deferred_pragma (parse_in, space, name, id, allow_expansion, false); }