This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Patch [3.4/3.3] G++ fix return with value in function returning void
- From: "Kaveh R. Ghazi" <ghazi at caip dot rutgers dot edu>
- To: gcc-patches at gcc dot gnu dot org
- Cc: mark at codesourcery dot com
- Date: Thu, 3 Apr 2003 00:46:49 -0500 (EST)
- Subject: Patch [3.4/3.3] G++ fix return with value in function returning void
Patch fixes:
> 7 `return' with a value, in function returning void
This one occurs because POP_TIMEVAR_AND_RETURN is defined to return a
value and is used in functions returning void. Even though in these
cases it's returning (void)0, this is bad ISO C. So I just
instantiate the body of that macro which calls timevar_pop and do a
plain "return". No real functional change.
Tested on solaris2.7, no regressions.
Ok for mainline and 3.3?
2003-04-01 Kaveh R. Ghazi <ghazi at caip dot rutgers dot edu>
* decl.c (push_local_name, push_class_level_binding,
maybe_inject_for_scope_var): Don't use POP_TIMEVAR_AND_RETURN in
functions returning void.
* decl2.c (add_using_namespace): Likewise.
diff -rup orig/egcc-CVS20030331/gcc/cp/decl.c egcc-CVS20030331/gcc/cp/decl.c
--- orig/egcc-CVS20030331/gcc/cp/decl.c 2003-03-30 21:01:24.000000000 -0500
+++ egcc-CVS20030331/gcc/cp/decl.c 2003-04-01 18:49:10.226929000 -0500
@@ -2497,7 +2505,8 @@ push_local_name (tree decl)
DECL_DISCRIMINATOR (decl) = 1;
VARRAY_TREE (local_names, i) = decl;
- POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, (void)0);
+ timevar_pop (TV_NAME_LOOKUP);
+ return;
}
}
@@ -4205,7 +4214,10 @@ push_class_level_binding (tree name, tre
/* The class_binding_level will be NULL if x is a template
parameter name in a member template. */
if (!class_binding_level)
- POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, (void)0);
+ {
+ timevar_pop (TV_NAME_LOOKUP);
+ return;
+ }
/* Make sure that this new member does not have the same name
as a template parameter. */
@@ -4255,7 +4267,8 @@ push_class_level_binding (tree name, tre
INHERITED_VALUE_BINDING_P (binding) = 0;
TREE_TYPE (shadow) = x;
IDENTIFIER_CLASS_VALUE (name) = x;
- POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, (void)0);
+ timevar_pop (TV_NAME_LOOKUP);
+ return;
}
}
@@ -7846,13 +7859,19 @@ maybe_inject_for_scope_var (tree decl)
{
timevar_push (TV_NAME_LOOKUP);
if (!DECL_NAME (decl))
- POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, (void)0);
+ {
+ timevar_pop (TV_NAME_LOOKUP);
+ return;
+ }
/* Declarations of __FUNCTION__ and its ilk appear magically when
the variable is first used. If that happens to be inside a
for-loop, we don't want to do anything special. */
if (DECL_PRETTY_FUNCTION_P (decl))
- POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, (void)0);
+ {
+ timevar_pop (TV_NAME_LOOKUP);
+ return;
+ }
if (current_binding_level->is_for_scope)
{
diff -rup orig/egcc-CVS20030331/gcc/cp/decl2.c egcc-CVS20030331/gcc/cp/decl2.c
--- orig/egcc-CVS20030331/gcc/cp/decl2.c 2003-03-30 14:03:34.000000000 -0500
+++ egcc-CVS20030331/gcc/cp/decl2.c 2003-04-01 18:49:42.794384000 -0500
@@ -3457,7 +3457,10 @@ add_using_namespace (tree user, tree use
timevar_push (TV_NAME_LOOKUP);
/* Using oneself is a no-op. */
if (user == used)
- POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, (void)0);
+ {
+ timevar_pop (TV_NAME_LOOKUP);
+ return;
+ }
my_friendly_assert (TREE_CODE (user) == NAMESPACE_DECL, 380);
my_friendly_assert (TREE_CODE (used) == NAMESPACE_DECL, 380);
/* Check if we already have this. */
@@ -3467,7 +3470,8 @@ add_using_namespace (tree user, tree use
if (!indirect)
/* Promote to direct usage. */
TREE_INDIRECT_USING (t) = 0;
- POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, (void)0);
+ timevar_pop (TV_NAME_LOOKUP);
+ return;
}
/* Add used to the user's using list. */