This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: PATCH RFA: Increase support for restrict qualifier
- From: "Joseph S. Myers" <joseph at codesourcery dot com>
- To: Ian Lance Taylor <ian at airs dot com>
- Cc: gcc-patches at gcc dot gnu dot org, rth at redhat dot com
- Date: Sat, 1 Oct 2005 10:31:05 +0000 (UTC)
- Subject: Re: PATCH RFA: Increase support for restrict qualifier
- References: <20050925091934.27915.qmail@gossamer.airs.com><1127660065.11273.41.camel@dyn9002242081> <m3wtl14wm6.fsf_-_@gossamer.airs.com><m3ek76vss7.fsf@gossamer.airs.com>
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)