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

Re: [PATCH] Fix -Wunused-but-set-* invalid warning on component ref at the end of stmt expression


I would like to PING this. Bootstrap has been broken a couple of days.
Otherwise, please commit a workaround adding
-Wno-error=set-but-not-used where appropriate.

Cheers,

Manuel.

On 8 April 2010 11:28, Jakub Jelinek <jakub@redhat.com> wrote:
> Hi!
>
> Honza reported last night on IRC that with older glibc headers
> bootstrap fails because of an invalid warning turned into error
> about __u in:
> # ? define __WAIT_INT(status) \
> ?(__extension__ ({ union { __typeof(status) __in; int __i; } __u; \
> ? ? ? ? ? ? ? ? ? ?__u.__in = (status); __u.__i; }))
> where __WAIT_INT as whole has been read.
>
> The following patch fixes it, bootstrapped/regtested on x86_64-linux
> and i686-linux. ?Ok for trunk?
>
> 2010-04-08 ?Jakub Jelinek ?<jakub@redhat.com>
>
> ? ? ? ?* c-typeck.c (c_process_expr_stmt): Call mark_exp_read even
> ? ? ? ?for exprs satisfying handled_component_p.
>
> ? ? ? ?* gcc.dg/Wunused-var-7.c: New test.
>
> --- gcc/c-typeck.c.jj ? 2010-04-08 08:49:45.000000000 +0200
> +++ gcc/c-typeck.c ? ? ?2010-04-08 09:20:05.000000000 +0200
> @@ -8826,11 +8826,13 @@ c_process_expr_stmt (location_t loc, tre
> ? ? ? && warn_unused_value)
> ? ? emit_side_effect_warnings (loc, expr);
>
> + ?if (DECL_P (expr) || handled_component_p (expr))
> + ? ?mark_exp_read (expr);
> +
> ? /* If the expression is not of a type to which we cannot assign a line
> ? ? ?number, wrap the thing in a no-op NOP_EXPR. ?*/
> ? if (DECL_P (expr) || CONSTANT_CLASS_P (expr))
> ? ? {
> - ? ? ?mark_exp_read (expr);
> ? ? ? expr = build1 (NOP_EXPR, TREE_TYPE (expr), expr);
> ? ? ? SET_EXPR_LOCATION (expr, loc);
> ? ? }
> --- gcc/testsuite/gcc.dg/Wunused-var-7.c.jj ? ? 2010-04-08 09:27:43.000000000 +0200
> +++ gcc/testsuite/gcc.dg/Wunused-var-7.c ? ? ? ?2010-04-08 09:25:56.000000000 +0200
> @@ -0,0 +1,29 @@
> +/* { dg-do compile } */
> +/* { dg-options "-Wunused -W" } */
> +
> +int
> +f1 (unsigned int x)
> +{
> + ?int c = ({ union { unsigned int a; int b; } u; u.a = x; u.b; });
> + ?return c;
> +}
> +
> +void
> +f2 (void)
> +{
> + ?struct S { int i; } a;
> + ?int b[1];
> + ?a.i = 1;
> + ?a.i; ? ? ? ? ? ? ? ? ? ? ? ? /* { dg-warning "with no effect" } */
> + ?b[0] = 1;
> + ?b[0]; ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?/* { dg-warning "with no effect" } */
> +}
> +
> +void
> +f3 (void)
> +{
> + ?struct S { int i; } a; ? ? ? /* { dg-warning "set but not used" } */
> + ?int b[1]; ? ? ? ? ? ? ? ? ? ?/* { dg-warning "set but not used" } */
> + ?a.i = 1;
> + ?b[0] = 1;
> +}
>
> ? ? ? ?Jakub
>


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