OSDN Git Service

PR c/39889
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 26 Apr 2009 18:51:07 +0000 (18:51 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 26 Apr 2009 18:51:07 +0000 (18:51 +0000)
* stmt.c (warn_if_unused_value): Look through NON_LVALUE_EXPR.

* gcc.dg/Wunused-value-3.c: New test.

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

gcc/ChangeLog
gcc/fortran/ChangeLog
gcc/stmt.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/Wunused-value-3.c [new file with mode: 0644]

index 480a6bf..6770f23 100644 (file)
@@ -1,4 +1,9 @@
-2009-04-22  Jakub Jelinek  <jakub@redhat.com>
+2009-04-26  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c/39889
+       * stmt.c (warn_if_unused_value): Look through NON_LVALUE_EXPR.
+
+2009-04-26  Jakub Jelinek  <jakub@redhat.com>
 
        * tree-nested.c (get_nonlocal_vla_type): If not optimizing, call
        note_nonlocal_vla_type for nonlocal VLAs.
index d39b713..6c2a442 100644 (file)
@@ -1,3 +1,15 @@
+2009-04-26  Jakub Jelinek  <jakub@redhat.com>
+
+       * trans-decl.c: Include pointer-set.h.
+       (nonlocal_dummy_decl_pset, tree nonlocal_dummy_decls): New variables.
+       (gfc_nonlocal_dummy_array_decl): New function.
+       (gfc_get_symbol_decl): Call it for non-local dummy args with saved
+       descriptor.
+       (gfc_get_symbol_decl): Set DECL_BY_REFERENCE when needed.
+       (gfc_generate_function_code): Initialize nonlocal_dummy_decl{s,_pset},
+       chain it to outermost block's vars, destroy it afterwards.
+       * Make-lang.in (trans-decl.o): Depend on pointer-set.h.
+
 2009-04-25  Janus Weil  <janus@gcc.gnu.org>
 
        PR fortran/39688
index e2688ef..6dc32fd 100644 (file)
@@ -1418,6 +1418,7 @@ warn_if_unused_value (const_tree exp, location_t locus)
       goto restart;
 
     case SAVE_EXPR:
+    case NON_LVALUE_EXPR:
       exp = TREE_OPERAND (exp, 0);
       goto restart;
 
index 5faeffc..7acde8d 100644 (file)
@@ -1,14 +1,7 @@
 2009-04-26  Jakub Jelinek  <jakub@redhat.com>
 
-       * trans-decl.c: Include pointer-set.h.
-       (nonlocal_dummy_decl_pset, tree nonlocal_dummy_decls): New variables.
-       (gfc_nonlocal_dummy_array_decl): New function.
-       (gfc_get_symbol_decl): Call it for non-local dummy args with saved
-       descriptor.
-       (gfc_get_symbol_decl): Set DECL_BY_REFERENCE when needed.
-       (gfc_generate_function_code): Initialize nonlocal_dummy_decl{s,_pset},
-       chain it to outermost block's vars, destroy it afterwards.
-       * Make-lang.in (trans-decl.o): Depend on pointer-set.h.
+       PR c/39889
+       * gcc.dg/Wunused-value-3.c: New test.
 
 2009-04-26  Joseph Myers  <joseph@codesourcery.com>
 
diff --git a/gcc/testsuite/gcc.dg/Wunused-value-3.c b/gcc/testsuite/gcc.dg/Wunused-value-3.c
new file mode 100644 (file)
index 0000000..333ddea
--- /dev/null
@@ -0,0 +1,9 @@
+/* PR c/39889 */
+/* { dg-do compile } */
+/* { dg-options "-Wunused-value" } */
+
+int x;
+int foo (void)
+{
+  return (1 ? x = 0 : (void) 0), 0; /* { dg-bogus "value computed is not used" } */
+}