From: Jakub Jelinek Date: Mon, 7 Jun 2010 17:49:06 +0000 (+0200) Subject: re PR c++/44443 (-Wunused-but-set-variable problem with unused attribute on type) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=026698d28e6eac591edfc8b1fd397e73b0503c56;p=gcc.git re PR c++/44443 (-Wunused-but-set-variable problem with unused attribute on type) PR c++/44443 * decl.c (initialize_local_var): If TREE_USED is set on the type, set also DECL_READ_P on the decl. * c-c++-common/Wunused-var-11.c: New test. From-SVN: r160387 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 6e4c35eb18a..622a79349b0 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2010-06-07 Jakub Jelinek + + PR c++/44443 + * decl.c (initialize_local_var): If TREE_USED is set on the type, + set also DECL_READ_P on the decl. + 2010-05-25 Dodji Seketeli PR c++/44188 diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index c9f864a6eaf..171e160b2af 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -5508,6 +5508,8 @@ initialize_local_var (tree decl, tree init) /* Compute and store the initial value. */ already_used = TREE_USED (decl) || TREE_USED (type); + if (TREE_USED (type)) + DECL_READ_P (decl) = 1; /* Generate a cleanup, if necessary. */ cleanup = cxx_maybe_build_cleanup (decl); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 392e0bf2f38..a2ac15621ce 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2010-06-07 Jakub Jelinek + + PR c++/44443 + * c-c++-common/Wunused-var-11.c: New test. + 2010-06-07 Jan Hubicka * gcc.dg/ipa/pure-const-1.c: New testcase. diff --git a/gcc/testsuite/c-c++-common/Wunused-var-11.c b/gcc/testsuite/c-c++-common/Wunused-var-11.c new file mode 100644 index 00000000000..a59ef814938 --- /dev/null +++ b/gcc/testsuite/c-c++-common/Wunused-var-11.c @@ -0,0 +1,12 @@ +/* PR c++/44443 */ +/* { dg-options "-Wunused" } */ +/* { dg-do compile } */ + +int i; + +void +f1 () +{ + const int * __attribute__((unused)) a = &i; + const int *b __attribute__((unused)) = &i; +}