On Mon, Jun 06, 2016 at 03:06:18PM +0000, Joseph Myers wrote: > On Tue, 31 May 2016, Marek Polacek wrote: > > > > diff --git gcc/testsuite/c-c++-common/attr-may-alias-1.c > > > gcc/testsuite/c-c++-common/attr-may-alias-1.c > > > index e69de29..978b9a5 100644 > > > --- gcc/testsuite/c-c++-common/attr-may-alias-1.c > > > +++ gcc/testsuite/c-c++-common/attr-may-alias-1.c > > > @@ -0,0 +1,26 @@ > > > +/* { dg-do compile } */ > > > +/* { dg-options "-O2 -Wall" } */ > > > + > > > +typedef int T __attribute__((may_alias)); > > > + > > > +extern T *p; > > > +extern int *p; > > > + > > > +extern int *p2; > > > +extern T *p2; > > > + > > > +void fn1 (T); > > > +void fn1 (int); > > > + > > > +void fn2 (int); > > > +void fn2 (T); > > > + > > > +/* Ensure that the composite types have may_alias. */ > > > +void > > > +f (long *i) > > > +{ > > > + *i = *(__typeof (*p) *) &p; > > > + asm ("" : : "r" (*p)); > > > + *i = *(__typeof (*p2) *) &p2; > > > + asm ("" : : "r" (*p2)); > > I don't see how this test is supposed to verify properties of the > composite type. I'd expect you to need to verify that something does not > get optimized away, that would get optimized away in the absence of > may_alias.
Well, were it not for the may_alias attribute, we'd warn about type punning (hence the -O2), so I thought that this test would be enough. Marek