diff options
author | Marek Polacek <polacek@redhat.com> | 2014-05-02 18:09:42 +0000 |
---|---|---|
committer | Marek Polacek <mpolacek@gcc.gnu.org> | 2014-05-02 18:09:42 +0000 |
commit | 19fc9faaaf98b3c45ede31da2e3cb970ef7b372a (patch) | |
tree | 071af8206b3e246f7368ae1b77b50da2d378bf6f /gcc | |
parent | 6577374eaa1de4e387f4a67c300133922dd52707 (diff) | |
download | gcc-19fc9faaaf98b3c45ede31da2e3cb970ef7b372a.zip gcc-19fc9faaaf98b3c45ede31da2e3cb970ef7b372a.tar.gz gcc-19fc9faaaf98b3c45ede31da2e3cb970ef7b372a.tar.bz2 |
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
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/c/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/c/c-typeck.c | 12 | ||||
-rw-r--r-- | gcc/cp/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/cp/typeck.c | 8 |
4 files changed, 22 insertions, 7 deletions
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index e3c13fe..b32e4fd 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,5 +1,9 @@ 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. (pedwarn_init): Likewise. * c-typeck.c (error_init): Make static and move above. diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c index b95fd89..f7ad91e 100644 --- a/gcc/c/c-typeck.c +++ b/gcc/c/c-typeck.c @@ -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: diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 4d16855..7729cb9 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -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 diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 8b7cb8d..7b28a9a 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -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; } } |