]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c/38957 (return of local variable pointer)
authorJakub Jelinek <jakub@gcc.gnu.org>
Sat, 24 Jan 2009 21:36:09 +0000 (22:36 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Sat, 24 Jan 2009 21:36:09 +0000 (22:36 +0100)
PR c/38957
* c-typeck.c (c_finish_return): Handle POINTER_PLUS_EXPR the same way
as PLUS_EXPR.

* gcc.dg/pr38957.c: New test.

From-SVN: r143654

gcc/ChangeLog
gcc/c-typeck.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr38957.c [new file with mode: 0644]

index 0c957db3b6a3080ca34b3c0aeac5a3454d030018..ecf9e4670418cff1bd69b136dccc0dff9203e65d 100644 (file)
@@ -1,3 +1,9 @@
+2009-01-24  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c/38957
+       * c-typeck.c (c_finish_return): Handle POINTER_PLUS_EXPR the same way
+       as PLUS_EXPR.
+
 2009-01-24  Julian Brown  <julian@codesourcery.com>
 
        * config/arm/t-linux-eabi (LIB2FUNCS_STATIC_EXTRA): Add
index 35c8d232878353824b00d6b8faf2f6ba3fcd0459..4b9b2b30d00c88396a359173c63e9d035cea0616 100644 (file)
@@ -7226,8 +7226,10 @@ c_finish_return (tree retval)
        {
          switch (TREE_CODE (inner))
            {
-           CASE_CONVERT:   case NON_LVALUE_EXPR:
+           CASE_CONVERT:
+           case NON_LVALUE_EXPR:
            case PLUS_EXPR:
+           case POINTER_PLUS_EXPR:
              inner = TREE_OPERAND (inner, 0);
              continue;
 
index 7e40d4e49585e47f9b5bcc26d315b15db338f053..5425b0250da703076b7b8e86b3769af13d70dc39 100644 (file)
@@ -1,8 +1,13 @@
-2009-01-24 David Billinghurst (billingd@gcc.gnu.org)
+2009-01-24  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c/38957
+       * gcc.dg/pr38957.c: New test.
+
+2009-01-24  David Billinghurst  <billingd@gcc.gnu.org>
 
        PR fortran/38955
        * gfortran.dg/array_constructor_24.f: Allow tolerance when
-       comparing floats
+       comparing floats.
 
 2009-01-24  Sebastian Pop  <sebastian.pop@amd.com>
 
diff --git a/gcc/testsuite/gcc.dg/pr38957.c b/gcc/testsuite/gcc.dg/pr38957.c
new file mode 100644 (file)
index 0000000..f94cd76
--- /dev/null
@@ -0,0 +1,16 @@
+/* PR c/38957 */
+/* { dg-do compile } */
+
+char *
+foo (void)
+{
+  char a[2];
+  return a+1;  /* { dg-warning "returns address of local variable" } */
+}
+
+char *
+bar (void)
+{
+  char a[2];
+  return a;    /* { dg-warning "returns address of local variable" } */
+}