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]

[PATCH] Fix bogus C++ warning


Hi!

C++ warns in the testcase below:
warning: the address of `void foo()', will always be `true'
which is bogus.
Dunno why H.J. hasn't submitted this, ok to commit?

2001-08-03  H.J. Lu  <hjl@gnu.org>

	* cvt.c (ocp_convert): Don't warn the address of a weak
	function is always `true'.

	* g++.dg/warn/weak1.C: New test.

--- gcc/cp/cvt.c.jj	Sat Aug 18 22:10:48 2001
+++ gcc/cp/cvt.c	Fri Oct 12 17:30:50 2001
@@ -814,7 +814,7 @@ ocp_convert (type, expr, convtype, flags
 	  else if (TREE_CODE (expr) == ADDR_EXPR 
 		   && TREE_CODE (TREE_OPERAND (expr, 0)) == FUNCTION_DECL)
 	    fn = TREE_OPERAND (expr, 0);
-	  if (fn)
+	  if (fn && !DECL_WEAK (fn))
 	    cp_warning ("the address of `%D', will always be `true'", fn);
 	  return cp_truthvalue_conversion (e);
 	}
--- gcc/testsuite/g++.dg/warn/weak1.C.jj	Fri Oct 12 17:30:50 2001
+++ gcc/testsuite/g++.dg/warn/weak1.C	Fri Oct 12 17:30:50 2001
@@ -0,0 +1,12 @@
+// { dg-do run }
+
+extern void foo (void) __attribute__ ((weak));
+
+int
+main ()
+{
+  if (&foo)
+    foo ();
+
+  return 0;
+}

	Jakub


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