c-typeck.c (c_finish_return): Separate warning_at calls.
authorMarek Polacek <polacek@redhat.com>
Fri, 2 May 2014 18:09:42 +0000 (18:09 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Fri, 2 May 2014 18:09:42 +0000 (18:09 +0000)
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

gcc/c/ChangeLog
gcc/c/c-typeck.c
gcc/cp/ChangeLog
gcc/cp/typeck.c

index e3c13fec9d2e780230d5d048c92710a60d98a973..b32e4fd196d4d420fb84f538476b43a7e667a304 100644 (file)
@@ -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.
index b95fd895d4fdcb76dbd6c9cd6e9b8d9cf920bb1f..f7ad91ed1c76ef78d9c1fcab3953f21627ef469a 100644 (file)
@@ -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:
index 4d16855390e5ff765ba62ba350df591c9b3df524..7729cb9d8c7281e039279b5b516e889f7a58eb6d 100644 (file)
@@ -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
index 8b7cb8df17a2c2ffb49ef36b480055766c0082f2..7b28a9a58695b919c89e1cee9a388337ef8c4812 100644 (file)
@@ -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;
     }
 }