OSDN Git Service

PR c/38957
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 24 Jan 2009 21:36:09 +0000 (21:36 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 24 Jan 2009 21:36:09 +0000 (21:36 +0000)
* c-typeck.c (c_finish_return): Handle POINTER_PLUS_EXPR the same way
as PLUS_EXPR.

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

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@143654 138bc75d-0d04-0410-961f-82ee72b054a4

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

index 0c957db..ecf9e46 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 35c8d23..4b9b2b3 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 7e40d4e..5425b02 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" } */
+}