c-typeck.c (c_finish_return): Separate warning_at calls.
c/ * c-typeck.c (c_finish_return): Separate warning_at calls. cp/ * typeck.c (maybe_warn_about_returning_address_of_local): Separate warning_at calls. From-SVN: r210012
This commit is contained in:
parent
6577374eaa
commit
19fc9faaaf
4 changed files with 22 additions and 7 deletions
|
@ -1,3 +1,7 @@
|
|||
2014-05-02 Marek Polacek <polacek@redhat.com>
|
||||
|
||||
* c-typeck.c (c_finish_return): Separate warning_at calls.
|
||||
|
||||
2014-05-02 Marek Polacek <polacek@redhat.com>
|
||||
|
||||
* c-tree.h (error_init): Remove declaration.
|
||||
|
|
|
@ -9273,10 +9273,14 @@ c_finish_return (location_t loc, tree retval, tree origtype)
|
|||
&& !DECL_EXTERNAL (inner)
|
||||
&& !TREE_STATIC (inner)
|
||||
&& DECL_CONTEXT (inner) == current_function_decl)
|
||||
warning_at (loc,
|
||||
OPT_Wreturn_local_addr, "function returns address "
|
||||
"of %s", TREE_CODE (inner) == LABEL_DECL
|
||||
? "label" : "local variable");
|
||||
{
|
||||
if (TREE_CODE (inner) == LABEL_DECL)
|
||||
warning_at (loc, OPT_Wreturn_local_addr,
|
||||
"function returns address of label");
|
||||
else
|
||||
warning_at (loc, OPT_Wreturn_local_addr,
|
||||
"function returns address of local variable");
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
2014-05-02 Marek Polacek <polacek@redhat.com>
|
||||
|
||||
* typeck.c (maybe_warn_about_returning_address_of_local): Separate
|
||||
warning_at calls.
|
||||
|
||||
2014-05-01 Marek Polacek <polacek@redhat.com>
|
||||
|
||||
PR c/43395
|
||||
|
|
|
@ -8309,10 +8309,12 @@ maybe_warn_about_returning_address_of_local (tree retval)
|
|||
if (TREE_CODE (valtype) == REFERENCE_TYPE)
|
||||
warning (OPT_Wreturn_local_addr, "reference to local variable %q+D returned",
|
||||
whats_returned);
|
||||
else if (TREE_CODE (whats_returned) == LABEL_DECL)
|
||||
warning (OPT_Wreturn_local_addr, "address of label %q+D returned",
|
||||
whats_returned);
|
||||
else
|
||||
warning (OPT_Wreturn_local_addr, "address of %s %q+D returned",
|
||||
TREE_CODE (whats_returned) == LABEL_DECL
|
||||
? "label" : "local variable", whats_returned);
|
||||
warning (OPT_Wreturn_local_addr, "address of local variable %q+D "
|
||||
"returned", whats_returned);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue