This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[basic-improvements] N-way choice followup


It turns out that the previous patch for N-way choices in specs was
not complete.  There is another parser for %{...} constructs, which
had not been updated for either patch I submitted.  Its sole function
is to decide when to issue warning messages of the form

gcc: unrecognized option `D__GCC_FLOAT_NOT_NEEDED'

Thus we were getting a whole bunch of spurious warnings.

The appended patch corrects this problem.  It also removes the '@'
Makefile flag from one category of commands generated by mklibgcc,
because its presence caused me to waste about half an hour finding out
why a command issued from libgcc.mk apparently produced these warnings
but an identical command issued directly from the shell prompt didn't.
(When what was actually going on was the warnings were coming from the
hidden command with the @-prefix.)

I would have liked to get rid of the extra parser and just set the
'switch validated' flag bits as part of normal processing, but this
breaks the existing invariant that switches meaningful to language A
are silently ignored when compiling language B.

Bootstrap in progress on i686-linux, should be done in about three
hours.  Assuming success, OK to apply to basic-improvements?

zw

	* gcc.c (validate_switches): Handle all new forms of spec
	syntax introduced recently.  Now returns a char *.
	(validate_all_switches): Repetitive logic broken out to...
	(validate_switches_from_spec): ...here.
	* mklibgcc.in: Don't @-flag commands to generate .oS files.

===================================================================
Index: gcc.c
--- gcc.c	26 Sep 2002 06:57:04 -0000	1.336.4.3
+++ gcc.c	30 Sep 2002 00:30:23 -0000
@@ -306,8 +306,9 @@ static int do_spec_1		PARAMS ((const cha
 static int do_spec_2		PARAMS ((const char *));
 static const char *find_file	PARAMS ((const char *));
 static int is_directory		PARAMS ((const char *, const char *, int));
-static void validate_switches	PARAMS ((const char *));
+static const char *validate_switches	PARAMS ((const char *));
 static void validate_all_switches PARAMS ((void));
+static inline void validate_switches_from_spec PARAMS ((const char *));
 static void give_switch		PARAMS ((int, int));
 static int used_arg		PARAMS ((const char *, int));
 static int default_arg		PARAMS ((const char *, int));
@@ -6528,89 +6529,106 @@ notice VPARAMS ((const char *msgid, ...)
   VA_CLOSE (ap);
 }
 
+static inline void
+validate_switches_from_spec (spec)
+     const char *spec;
+{
+  const char *p = spec;
+  char c;
+  while ((c = *p++))
+    if (c == '%' && (*p == '{' || *p == '<' || (*p == 'W' && *++p == '{')))
+      /* We have a switch spec.  */
+      p = validate_switches (p + 1);
+}
+
 static void
 validate_all_switches ()
 {
   struct compiler *comp;
-  const char *p;
-  char c;
   struct spec_list *spec;
 
   for (comp = compilers; comp->spec; comp++)
-    {
-      p = comp->spec;
-      while ((c = *p++))
-	if (c == '%' && (*p == '{' || (*p == 'W' && *++p == '{')))
-	  /* We have a switch spec.  */
-	  validate_switches (p + 1);
-    }
+    validate_switches_from_spec (comp->spec);
 
   /* Look through the linked list of specs read from the specs file.  */
   for (spec = specs; spec; spec = spec->next)
-    {
-      p = *(spec->ptr_spec);
-      while ((c = *p++))
-	if (c == '%' && (*p == '{' || (*p == 'W' && *++p == '{')))
-	  /* We have a switch spec.  */
-	  validate_switches (p + 1);
-    }
+    validate_switches_from_spec (*spec->ptr_spec);
 
-  p = link_command_spec;
-  while ((c = *p++))
-    if (c == '%' && (*p == '{' || (*p == 'W' && *++p == '{')))
-      /* We have a switch spec.  */
-      validate_switches (p + 1);
+  validate_switches_from_spec (link_command_spec);
 }
 
 /* Look at the switch-name that comes after START
    and mark as valid all supplied switches that match it.  */
 
-static void
+static const char *
 validate_switches (start)
      const char *start;
 {
   const char *p = start;
-  const char *filter;
+  const char *atom;
+  size_t len;
   int i;
-  int suffix;
-
-  if (*p == '|')
-    ++p;
-
+  bool suffix = false;
+  bool starred = false;
+  
+#define SKIP_WHITE() do { while (*p == ' ' || *p == '\t') p++; } while (0)
+  
 next_member:
+  SKIP_WHITE ();
+
   if (*p == '!')
-    ++p;
+    p++;
 
-  suffix = 0;
+  SKIP_WHITE ();
   if (*p == '.')
-    suffix = 1, ++p;
+    suffix = true, p++;
 
-  filter = p;
-  while (*p != ':' && *p != '}' && *p != '|' && *p != '&')
+  atom = p;
+  while (ISIDNUM (*p) || *p == '-' || *p == '+' || *p == '='
+	 || *p == ',' || *p == '.')
     p++;
+  len = p - atom;
 
-  if (suffix)
-    ;
-  else if (p[-1] == '*')
+  if (*p == '*')
+    starred = true, p++;
+
+  SKIP_WHITE ();
+
+  if (!suffix)
     {
       /* Mark all matching switches as valid.  */
       for (i = 0; i < n_switches; i++)
-	if (!strncmp (switches[i].part1, filter, p - filter - 1))
+	if (!strncmp (switches[i].part1, atom, len)
+	    && (starred || switches[i].part1[len] == 0))
 	  switches[i].validated = 1;
     }
-  else
+
+  p++;
+  if (p[-1] == '|' || p[-1] == '&')
+    goto next_member;
+
+  if (p[-1] == ':')
     {
-      /* Mark an exact matching switch as valid.  */
-      for (i = 0; i < n_switches; i++)
+      while (*p && *p != ';' && *p != '}')
 	{
-	  if (!strncmp (switches[i].part1, filter, p - filter)
-	      && switches[i].part1[p - filter] == 0)
-	    switches[i].validated = 1;
+	  if (*p == '%')
+	    {
+	      p++;
+	      if (*p == '{' || *p == '<')
+		p = validate_switches (p+1);
+	      else if (p[0] == 'W' && p[1] == '{')
+		p = validate_switches (p+2);
+	    }
+	  p++;
 	}
+
+      p++;
+      if (p[-1] == ';')
+	goto next_member;
     }
 
-  if (*p++ == '|' || p[-1] == '&')
-    goto next_member;
+  return p;
+#undef SKIP_WHITE
 }
 
 /* Check whether a particular argument was used.  The first time we
===================================================================
Index: mklibgcc.in
--- mklibgcc.in	31 May 2002 20:11:47 -0000	1.47
+++ mklibgcc.in	30 Sep 2002 00:30:23 -0000
@@ -286,7 +286,7 @@ for ml in $MULTILIBS; do
       # .oS objects will have all non-local symbol definitions .hidden
       oS=`echo ${o} | sed s~${objext}'$~.oS~g'`
       echo "${oS}: stmp-dirs ${o}"
-      echo '	@$(NM_FOR_TARGET) '${SHLIB_NM_FLAGS} ${o}' | $(AWK) '\''NF == 3 { print "\t.hidden", $$3 }'\'' | $(GCC_FOR_TARGET) $(LIBGCC2_CFLAGS) '${flags}' -r -nostdinc -nostdlib -o $@ '${o}' -xassembler -'
+      echo '	$(NM_FOR_TARGET) '${SHLIB_NM_FLAGS} ${o}' | $(AWK) '\''NF == 3 { print "\t.hidden", $$3 }'\'' | $(GCC_FOR_TARGET) $(LIBGCC2_CFLAGS) '${flags}' -r -nostdinc -nostdlib -o $@ '${o}' -xassembler -'
       libgcc_a_objs="${libgcc_a_objs} ${oS}"
     done
   fi






Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]