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 RFA: Increase support for restrict qualifier


On Sat, 30 Sep 2005, Ian Lance Taylor wrote:

> I looked into code like
>     int foo (int a[restrict 10]) { }
> It turns out that neither my previous patch nor this one handle that
> code.  Interestingly, the parameter is turned into a pointer, and
> DECL_POINTER_ALIAS_SET for the decl is set to a unique alias set, but
> the type is not marked as restricted.  That is because grokdeclarator
> in c-decl.c, in the case of decl_context == PARM, turns the ARRAY_TYPE
> into a pointer type, and passes array_ptr_quals to
> c_apply_type_quals_to_decl, but does not build a qualified version of
> the pointer type using array_ptr_quals.  That looks like a mistake to
> me, but I'm not sure whether it is or not.  If it is a mistake, then
> changing grokdeclarator to turn the array into a restricted pointer
> will activate this patch.  If it is not a mistake, then this patch
> should check DECL_POINTER_ALIAS_SET_KNOWN_P as well as (or perhaps
> instead of) TYPE_RESTRICT in internal_get_tmp_var.

It looks like a bug to me.  A suitable testcase illustrating this is

int f(int a[restrict]) { int **b = &a; }

which should get a "discards qualifiers" diagnostic.

I'd hope it's possible to write a testcase for the optimization 
improvements in the present patch as well.

-- 
Joseph S. Myers               http://www.srcf.ucam.org/~jsm28/gcc/
    jsm@polyomino.org.uk (personal mail)
    joseph@codesourcery.com (CodeSourcery mail)
    jsm28@gcc.gnu.org (Bugzilla assignments and CCs)


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