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]

Automatic rejection of unwanted no- options


I noticed that the Fortran front end has an awfully large number of -f
switches that do not take the no- form.  This patch allows you to specify
that a -W or -f switch doesn't take a no- form in the definition file,
which should make converting Fortran easier down the line.

Neil.

	* c-opts.c (CL_REJECT_NEGATIVE): New.
	(c_common_decode_option): Update to use it.
	* c.opt: Update documentation; use RejectNegative.
	* opts.sh: Handle RejectNegative.

Index: c-opts.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-opts.c,v
retrieving revision 1.50
diff -u -p -b -r1.50 c-opts.c
--- c-opts.c	31 May 2003 21:18:21 -0000	1.50
+++ c-opts.c	1 Jun 2003 22:14:13 -0000
@@ -125,6 +125,7 @@ static void finish_options PARAMS ((void
 #define CL_OBJCXX	(1 << 3) /* Only ObjC++.  */
 #define CL_JOINED	(1 << 4) /* If takes joined argument.  */
 #define CL_SEPARATE	(1 << 5) /* If takes a separate argument.  */
+#define CL_REJECT_NEGATIVE	(1 << 6) /* Reject no- form.  */
 
 #include "c-options.c"
 
@@ -398,9 +399,15 @@ c_common_decode_option (argc, argv)
   if (opt_index == N_OPTS)
     goto done;
 
-  result = 1;
   option = &cl_options[opt_index];
 
+  /* Reject negative form of switches that don't take negatives.  */
+  if (!on && (option->flags & CL_REJECT_NEGATIVE))
+    goto done;
+
+  /* We've recognised this switch.  */
+  result = 1;
+
   /* Sort out any argument the switch takes.  */
   if (option->flags & (CL_JOINED | CL_SEPARATE))
     {
@@ -629,9 +636,6 @@ c_common_decode_option (argc, argv)
       break;
 
     case OPT_Werror_implicit_function_declaration:
-      if (!on)
-	result = 0;
-      else
 	mesg_implicit_function_declaration = 2;
       break;
 
@@ -908,7 +912,7 @@ c_common_decode_option (argc, argv)
       break;
 
     case OPT_fdump_:
-      if (!on || !dump_switch_p (argv[0] + strlen ("-f")))
+      if (!dump_switch_p (argv[0] + strlen ("-f")))
 	result = 0;
       break;
 
@@ -1072,10 +1076,6 @@ c_common_decode_option (argc, argv)
       break;
 
     case OPT_ftabstop_:
-      /* Don't recognize -fno-tabstop=.  */
-      if (!on)
-	return 0;
-
       /* It is documented that we silently ignore silly values.  */
 	{
 	  char *endptr;
Index: c.opt
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c.opt,v
retrieving revision 1.2
diff -u -p -b -r1.2 c.opt
--- c.opt	1 Jun 2003 18:24:08 -0000	1.2
+++ c.opt	1 Jun 2003 22:14:13 -0000
@@ -24,7 +24,9 @@
 ; and each field appearing on its own line.  The first field is the
 ; command-line switch with the leading "-" removed.  All options
 ; beginning with "f" or "W" are implicitly assumed to take a "no-"
-; form; this form should not be listed.
+; form; this form should not be listed.  If you do not want this
+; negative form and you want it to be automatically rejected, add
+; RejectNegative to the second field.
 
 ; The second field is a space-separated list of which parts of the
 ; compiler recognize the switch.  Current valid entries are "C",
@@ -144,7 +146,7 @@ Werror
 C ObjC C++ ObjC++
 
 Werror-implicit-function-declaration
-C ObjC
+C ObjC RejectNegative
 
 Wfloat-equal
 C ObjC C++ ObjC++
@@ -339,7 +341,7 @@ fdollars-in-identifiers
 C ObjC C++ ObjC++
 
 fdump-
-C ObjC C++ ObjC++ Joined
+C ObjC C++ ObjC++ Joined RejectNegative
 
 felide-constructors
 C++ ObjC++
@@ -465,7 +467,7 @@ fstrict-prototype
 C++ ObjC++
 
 ftabstop=
-C ObjC C++ ObjC++ Joined
+C ObjC C++ ObjC++ Joined RejectNegative
 
 ftemplate-depth-
 C++ ObjC++ Joined
Index: opts.sh
===================================================================
RCS file: /cvs/gcc/gcc/gcc/opts.sh,v
retrieving revision 1.3
diff -u -p -b -r1.3 opts.sh
--- opts.sh	1 Jun 2003 18:24:08 -0000	1.3
+++ opts.sh	1 Jun 2003 22:14:13 -0000
@@ -48,8 +48,9 @@ cat "$@" | ${AWK} '
         if (langs ~ ":ObjC:") flags = flags " | CL_OBJC"
         if (langs ~ ":C\\+\\+:") flags = flags " | CL_CXX"
         if (langs ~ ":ObjC\\+\\+:") flags = flags " | CL_OBJCXX"
-        if (langs ~ ":Joined") flags = flags " | CL_JOINED"
-        if (langs ~ ":Separate") flags = flags " | CL_SEPARATE"
+        if (langs ~ ":Joined:") flags = flags " | CL_JOINED"
+        if (langs ~ ":Separate:") flags = flags " | CL_SEPARATE"
+        if (langs ~ ":RejectNegative:") flags = flags " | CL_REJECT_NEGATIVE"
 	sub( "^0 \\| ", "", flags )
 	return flags
     }


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