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 PR 14156, warning about returning addresses to parameters


Basically the problem is that the code does not check for parameters when
warning about the return was an address to a local variable. This patch
fixes that by adding the check.


Thanks,
Andrew Pinski

OK? Bootstrapped on powerpc-apple-darwin7.2.0 with no regressions?
Ok for 3.4 also, even though this is not a regression but a two simple fix?
Okay for 3.3.4 also as again this is a simple fix?



ChangeLog: * c-typeck.c (c_expand_return): Add check for PARM_DECL.

cp/ChangeLog:
	* typeck.c (maybe_warn_about_returning_address_of_location):
	Add check for PARM_DECL.


Patch:


Attachment: warning.diff.txt
Description: Text document




Testcase:


/* { dg-do compile } */

int * f( int a)
{
	return &a; /* { dg-warning "address" "" } */
}

int * g()
{
	int b = 0;

	return &b; /* { dg-warning "address" "" } */
}

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