This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH 1/3] improve detection of attribute conflicts (PR 81544)
On Wed, 9 Aug 2017, Martin Sebor wrote:
> > > diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-ccp-2.c
> > > b/gcc/testsuite/gcc.dg/tree-ssa/ssa-ccp-2.c
> > > index 146b76c..58a4742 100644
> > > --- a/gcc/testsuite/gcc.dg/tree-ssa/ssa-ccp-2.c
> > > +++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-ccp-2.c
> > > @@ -113,7 +113,7 @@ int test9 (int *intarr)
> > >
> > > int test99 (int *intarr)
> > > {
> > > - extern int foo9 (int) __attribute__ ((pure));
> > > + extern int foo9 (int) __attribute__ ((const));
> > > int h, v;
> > > g9 = 9;
> > > h = foo9 (g9);
> > >
> >
> > And why this? I'd avoid modifying existing tests like that unless
> > it's directly related to the new diagnostic.
>
> The same function is declared earlier on in the file with attribute
> const and the redeclaration with attribute pure triggers a warning
> due to the two being considered mutually exclusive.
const + pure is a *redundant* combination, but I think it should always
have the meaning of const regardless of the order in which they appear or
whether they appear on separate declarations. That's different from
combinations that are actually nonsensical. It's not clear to me that
const + pure should be diagnosed by default any more than declaring the
same function twice, with the const attribute both time, should be
diagnosed.
--
Joseph S. Myers
joseph@codesourcery.com