]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - gcc/opts.h
* coretypes.h (struct cl_option_handlers): Declare.
[thirdparty/gcc.git] / gcc / opts.h
index 674843a9497be67a33defb994a272c419bcf777e..6613da0c3b05d9b19ca64b96f46b246019eed51c 100644 (file)
@@ -135,6 +135,47 @@ struct cl_decoded_option
   int errors;
 };
 
+/* Structure describing a single option-handling callback.  */
+
+struct cl_option_handler_func
+{
+  /* The function called to handle the option.  */
+  bool (*handler) (size_t opt_index, const char *arg, int value,
+                  unsigned int lang_mask, int kind,
+                  const struct cl_option_handlers *handlers);
+
+  /* The mask that must have some bit in common with the flags for the
+     option for this particular handler to be used.  */
+  unsigned int mask;
+};
+
+/* Structure describing the callbacks used in handling options.  */
+
+struct cl_option_handlers
+{
+  /* Callback for an unknown option to determine whether to give an
+     error for it, and possibly store information to diagnose the
+     option at a later point.  Return true if an error should be
+     given, false otherwise.  */
+  bool (*unknown_option_callback) (const char *opt);
+
+  /* Callback to handle, and possibly diagnose, an option for another
+     language.  */
+  void (*wrong_lang_callback) (const char *text,
+                              const struct cl_option *option,
+                              unsigned int lang_mask);
+
+  /* Callback to call after the successful handling of any option.  */
+  void (*post_handling_callback) (size_t opt_index, const char *arg,
+                                 int value, unsigned int mask);
+
+  /* The number of individual handlers.  */
+  size_t num_handlers;
+
+  /* The handlers themselves.  */
+  struct cl_option_handler_func handlers[3];
+};
+
 /* Input file names.  */
 
 extern const char **in_fnames;
@@ -157,10 +198,15 @@ extern void decode_options (unsigned int argc, const char **argv,
 extern int option_enabled (int opt_idx);
 extern bool get_option_state (int, struct cl_option_state *);
 extern void set_option (int opt_index, int value, const char *arg, int);
-bool handle_option (int opt_index, int value, const char *arg,
-                   unsigned int lang_mask, int kind);
+bool handle_option (size_t opt_index, const char *arg, int value,
+                   unsigned int lang_mask, int kind,
+                   const struct cl_option_handlers *handlers);
+extern void read_cmdline_option (struct cl_decoded_option *decoded,
+                                unsigned int lang_mask,
+                                const struct cl_option_handlers *handlers);
 extern void register_warning_as_error_callback (void (*callback) (int));
 extern void enable_warning_as_error (const char *arg, int value,
-                                    unsigned int lang_mask);
+                                    unsigned int lang_mask,
+                                    const struct cl_option_handlers *handlers);
 extern void print_ignored_options (void);
 #endif