]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - gcc/genmultilib
PR fortran/95090 - ICE: identifier overflow
[thirdparty/gcc.git] / gcc / genmultilib
index 083259aa82ca085be7410faa92929eb429393f92..292ecc4e20dd7a2b9366c873a6a840a1ff580ec4 100644 (file)
@@ -1,6 +1,6 @@
 #!/bin/sh 
 # Generates multilib.h.
-#   Copyright (C) 1994-2016 Free Software Foundation, Inc.
+#   Copyright (C) 1994-2020 Free Software Foundation, Inc.
 
 #This file is part of GCC.
 
@@ -459,27 +459,41 @@ done
 echo "NULL"
 echo "};"
 
+# Generate a regular expression to validate option combinations.
+options_re=
+for set in ${options}; do
+  for opt in `echo ${set} | sed -e 's_[/|]_ _g' -e 's/+/./g' `; do
+    options_re="${options_re}${options_re:+|}${opt}"
+  done
+done
+options_re="^/((${options_re})/)*\$"
+
 # Output rules used for multilib reuse.
 echo ""
 echo "static const char *const multilib_reuse_raw[] = {"
 for rrule in ${multilib_reuse}; do
   # The left part of the rule are the options we used to build multilib.
   # The right part of the rule are the options that can reuse this multilib.
-  combo=`echo ${rrule} | sed -e 's/=.*$//' -e 's/\./=/g'`
-  copts=`echo ${rrule} | sed -e 's/^.*=//' -e 's/\./=/g'`
+  combo=`echo ${rrule} | sed -e 's/=.*$//' -e 's/\([^\\]\)\./\1=/g' -e 's/\\\././g'`
+  copts=`echo ${rrule} | sed -e 's/^.*=//' -e 's/\([^\\]\)\./\1=/g' -e 's/\\\././g'`
   # The variable ${combinations} are the option combinations we will build
   # multilib from.  If the combination in the left part of reuse rule isn't
   # in this variable, it means no multilib will be built for current reuse
   # rule.  Thus the reuse purpose specified by current rule is meaningless.
   if expr "${combinations} " : ".*/${combo}/.*" > /dev/null; then
-    combo="/${combo}/"
-    dirout=`./tmpmultilib3 "${combo}" "${todirnames}" "${toosdirnames}" "${enable_multilib}"`
-    copts="/${copts}/"
-    optout=`./tmpmultilib4 "${copts}" "${options}"`
-    # Output the line with all appropriate matches.
-    dirout="${dirout}" optout="${optout}" ./tmpmultilib2
+    if echo "/${copts}/" | grep -E "${options_re}" > /dev/null; then
+      combo="/${combo}/"
+      dirout=`./tmpmultilib3 "${combo}" "${todirnames}" "${toosdirnames}" "${enable_multilib}"`
+      copts="/${copts}/"
+      optout=`./tmpmultilib4 "${copts}" "${options}"`
+      # Output the line with all appropriate matches.
+      dirout="${dirout}" optout="${optout}" ./tmpmultilib2
+    else
+      echo "The rule ${rrule} contains an option absent from MULTILIB_OPTIONS." >&2
+      exit 1
+    fi
   else
-    echo "The rule ${rrule} is trying to reuse nonexistent multilib."
+    echo "The rule ${rrule} is trying to reuse nonexistent multilib." >&2
     exit 1
   fi
 done