Commit 19fc9faa by Marek Polacek Committed by Marek Polacek

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
parent 6577374e
2014-05-02 Marek Polacek <polacek@redhat.com> 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. * c-tree.h (error_init): Remove declaration.
(pedwarn_init): Likewise. (pedwarn_init): Likewise.
* c-typeck.c (error_init): Make static and move above. * c-typeck.c (error_init): Make static and move above.
......
...@@ -9273,10 +9273,14 @@ c_finish_return (location_t loc, tree retval, tree origtype) ...@@ -9273,10 +9273,14 @@ c_finish_return (location_t loc, tree retval, tree origtype)
&& !DECL_EXTERNAL (inner) && !DECL_EXTERNAL (inner)
&& !TREE_STATIC (inner) && !TREE_STATIC (inner)
&& DECL_CONTEXT (inner) == current_function_decl) && DECL_CONTEXT (inner) == current_function_decl)
warning_at (loc, {
OPT_Wreturn_local_addr, "function returns address " if (TREE_CODE (inner) == LABEL_DECL)
"of %s", TREE_CODE (inner) == LABEL_DECL warning_at (loc, OPT_Wreturn_local_addr,
? "label" : "local variable"); "function returns address of label");
else
warning_at (loc, OPT_Wreturn_local_addr,
"function returns address of local variable");
}
break; break;
default: default:
......
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> 2014-05-01 Marek Polacek <polacek@redhat.com>
PR c/43395 PR c/43395
......
...@@ -8309,10 +8309,12 @@ maybe_warn_about_returning_address_of_local (tree retval) ...@@ -8309,10 +8309,12 @@ maybe_warn_about_returning_address_of_local (tree retval)
if (TREE_CODE (valtype) == REFERENCE_TYPE) if (TREE_CODE (valtype) == REFERENCE_TYPE)
warning (OPT_Wreturn_local_addr, "reference to local variable %q+D returned", warning (OPT_Wreturn_local_addr, "reference to local variable %q+D returned",
whats_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 else
warning (OPT_Wreturn_local_addr, "address of %s %q+D returned", warning (OPT_Wreturn_local_addr, "address of local variable %q+D "
TREE_CODE (whats_returned) == LABEL_DECL "returned", whats_returned);
? "label" : "local variable", whats_returned);
return; return;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment