This is the mail archive of the gcc-bugs@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]

[Bug c++/14156] no warning for address of parameter


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-02-16 12:17 -------
Confirmed, this is an easy fix.
Checking also for PARM_DECL is what is needed:
Index: c-typeck.c
===============================================================
====
RCS file: /cvs/gcc/gcc/gcc/c-typeck.c,v
retrieving revision 1.277
diff -u -p -r1.277 c-typeck.c
--- c-typeck.c  12 Feb 2004 19:14:05 -0000      1.277
+++ c-typeck.c  16 Feb 2004 12:14:54 -0000
@@ -6207,7 +6207,8 @@ c_expand_return (tree retval)
              while (TREE_CODE_CLASS (TREE_CODE (inner)) == 'r')
                inner = TREE_OPERAND (inner, 0);
 
-             if (TREE_CODE (inner) == VAR_DECL
+             if ((TREE_CODE (inner) == VAR_DECL
+                  || TREE_CODE (inner) == PARM_DECL)
                  && ! DECL_EXTERNAL (inner)
                  && ! TREE_STATIC (inner)
                  && DECL_CONTEXT (inner) == current_function_decl)
Index: typeck.c
===============================================================
====
RCS file: /cvs/gcc/gcc/gcc/cp/typeck.c,v
retrieving revision 1.528
diff -u -p -r1.528 typeck.c
--- typeck.c    14 Feb 2004 00:49:12 -0000      1.528
+++ typeck.c    16 Feb 2004 12:16:14 -0000
@@ -5884,7 +5884,8 @@ maybe_warn_about_returning_address_of_lo
        }
     }
 
-  if (TREE_CODE (whats_returned) == VAR_DECL
+  if ((TREE_CODE (whats_returned) == VAR_DECL
+       || TREE_CODE (whats_returned) == PARM_DECL)
       && DECL_NAME (whats_returned)
       && DECL_FUNCTION_SCOPE_P (whats_returned)
       && !(TREE_STATIC (whats_returned)

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |pinskia at gcc dot gnu dot
                   |dot org                     |org
             Status|UNCONFIRMED                 |ASSIGNED
     Ever Confirmed|                            |1
           Keywords|                            |diagnostic
   Last reconfirmed|0000-00-00 00:00:00         |2004-02-16 12:17:11
               date|                            |
   Target Milestone|---                         |3.5.0


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14156


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