Hello,

bootstrapped on gcc master x86_64 and no extra failures generated on all
front ends.

Would this be ok for trunc?

regards,
Gaius


Allow front ends to register spec functions gcc/{gcc.cc,gcc.h} [PR108261]

This patch allows front ends to register spec functions.  It is motivated
by PR108261 which needs to retain the order of search path related
options in the modula-2 front end.

gcc/ChangeLog:

        * gcc.cc (add_spec_function):
        * gcc.h (add_spec_function):

diff --git a/gcc/gcc.cc b/gcc/gcc.cc
index becc56051a8..93e4e38389d 100644
--- a/gcc/gcc.cc
+++ b/gcc/gcc.cc
@@ -46,6 +46,7 @@ compilation is specified by a string called a "spec".  */
 #include "spellcheck.h"
 #include "opts-jobserver.h"
 #include "common/common-target.h"
+#include <vector>
 
 
 
@@ -1774,6 +1775,8 @@ static const struct spec_function static_spec_functions[] 
=
   { 0, 0 }
 };
 
+static std::vector<struct spec_function *>lang_spec_functions;
+
 static int processing_spec_function;
 
 /* Add appropriate libgcc specs to OBSTACK, taking into account
@@ -6825,9 +6828,25 @@ lookup_spec_function (const char *name)
     if (strcmp (sf->name, name) == 0)
       return sf;
 
+  for (auto *sf : lang_spec_functions)
+    if (strcmp (sf->name, name) == 0)
+      return sf;
+
   return NULL;
 }
 
+/* Add a new spec function.  */
+
+void
+add_spec_function (const char *name,
+                  const char *(*func) (int, const char **))
+{
+  struct spec_function *sf = XNEW (struct spec_function);
+  sf->name = name;
+  sf->func = func;
+  lang_spec_functions.push_back (sf);
+}
+
 /* Evaluate a spec function.  */
 
 static const char *
diff --git a/gcc/gcc.h b/gcc/gcc.h
index 19a61b373ee..f40de0f5520 100644
--- a/gcc/gcc.h
+++ b/gcc/gcc.h
@@ -73,6 +73,8 @@ struct spec_function
 extern int do_spec (const char *);
 extern void record_temp_file (const char *, int, int);
 extern void set_input (const char *);
+extern void add_spec_function (const char *name,
+                              const char *(*func) (int, const char **));
 
 /* Spec files linked with gcc.cc must provide definitions for these.  */
 

Reply via email to