This is the mail archive of the gcc-bugs@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]

patch for Re: Inappropriate Warning Cannot Be Turned Off



> > Hum, -Wnotanidiot should turn it off, though, we can debate the
> > spelling.
> 
> Hmm. It seems we agree on the feature, now somebody just needs to
> volunteer to write the patch :-)

As a lighthearted volunteer, far be it from me to refuse to implement
features with ridiculous names.

  % g++ -c -Wnotanidiot idiot.cc
  % g++ -c idiot.cc
   idiot.cc: In function `int main ()':
   idiot.cc:27: warning: choosing `Auto0<T>::operator T & () [with T =
   int]' over `Auto0<T>::operator const T & () const [with T = int]'
   idiot.cc:27: warning:   for conversion from `Auto0<int>' to `int'
   idiot.cc:27: warning:   because conversion sequence for the argument is
   better
   idiot.cc:27: warning: choosing `Auto0<T>::operator T & () [with T =
   int]' over `Auto0<T>::operator const T & () const [with T = int]'
   idiot.cc:27: warning:   for conversion from `Auto0<int>' to `int'
   idiot.cc:27: warning:   because conversion sequence for the argument is
   better
   idiot.cc:29: warning: choosing `Auto0<T>::operator T & () [with T =
   int]' over `Auto0<T>::operator const T & () const [with T = int]'
   idiot.cc:29: warning:   for conversion from `Auto0<int>' to `int'
   idiot.cc:29: warning:   because conversion sequence for the argument is
   better
  %

I leave to one of you to correct the spelling.  :-)  One thing,
though:  in the relevent file, there is already an extern declaration
of an "inhibit_warnings" variable, but it isn't currently used in the
file.  Maybe this should have been put to work instead; I don't know
what it does or where it gets set.  (Lighthearted, but also tired.)

Anyhow.


Index: gcc/cp/call.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/call.c,v
retrieving revision 1.220
diff -u -3 -r1.220 call.c
--- call.c	2000/05/31 19:27:11	1.220
+++ call.c	2000/06/06 22:36:40
@@ -38,6 +38,11 @@
 
 extern int inhibit_warnings;
 
+/* Nonzero means not to emit educational warnings about overload
+   resolution. */
+extern int warn_notanidiot;
+
+
 static tree build_new_method_call PARAMS ((tree, tree, tree, tree, int));
 
 static tree build_field_call PARAMS ((tree, tree, tree, tree));
@@ -3937,7 +3942,7 @@
   int is_method = 0;
 
   /* Give any warnings we noticed during overload resolution.  */
-  if (cand->warnings)
+  if (cand->warnings && !warn_notanidiot)
     for (val = cand->warnings; val; val = TREE_CHAIN (val))
       joust (cand, WRAPPER_PTR (TREE_VALUE (val)), 1);
 
Index: gcc/cp/decl2.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/decl2.c,v
retrieving revision 1.363
diff -u -3 -r1.363 decl2.c
--- decl2.c	2000/06/06 20:11:40	1.363
+++ decl2.c	2000/06/06 22:36:41
@@ -349,6 +349,11 @@
 
 int warn_nontemplate_friend = 1;
 
+/* Nonzero means not to emit educational warnings about overload
+   resolution. */
+
+int warn_notanidiot = 0;
+
 /* Nonzero means complain about deprecated features.  */
 
 int warn_deprecated = 1;
@@ -782,6 +787,8 @@
 	warn_nontemplate_friend = setting;
       else if (!strcmp (p, "deprecated"))
         warn_deprecated = setting;
+      else if (!strcmp (p, "notanidiot"))
+        warn_notanidiot = setting;
       else if (!strcmp (p, "comment"))
 	;			/* cpp handles this one.  */
       else if (!strcmp (p, "comments"))
Index: gcc/cp/lang-options.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/lang-options.h,v
retrieving revision 1.36
diff -u -3 -r1.36 lang-options.h
--- lang-options.h	2000/06/06 20:11:40	1.36
+++ lang-options.h	2000/06/06 22:36:41
@@ -126,6 +126,7 @@
   { "-Wno-reorder", "" },
   { "-Wsynth", "Warn when synthesis behaviour differs from Cfront" },
   { "-Wno-synth", "" },
+  { "-Wnotanidiot", "Don't warn about choices of conversion sequences during overload resolution" },
   { "-Wpmf-conversions", "" },
   { "-Wno-pmf-conversions", "Don't warn when type converting pointers to member functions" },
   { "-Weffc++", "Warn about violations of Effective C++ style rules" },




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