This is the mail archive of the
mailing list for the GCC project.
Re: libcpp: registering both a pragma and a pragma namespace with the same name
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Aldy Hernandez <aldyh at redhat dot com>
- Cc: Andrew Pinski <pinskia at gmail dot com>, Tom Tromey <tromey at redhat dot com>, "Iyer, Balaji V" <balaji dot v dot iyer at intel dot com>, gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 11 Apr 2013 14:36:09 +0200
- Subject: Re: libcpp: registering both a pragma and a pragma namespace with the same name
- References: <5165E691 dot 8020907 at redhat dot com> <CA+=Sn1k6u-4wk6mzivFtThAgLMBHJzfbzFTLFxM6Dj6iHOHw2g at mail dot gmail dot com> <20130411053231 dot GH16463 at tucnak dot redhat dot com> <5166A846 dot 6020604 at redhat dot com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Thu, Apr 11, 2013 at 07:10:46AM -0500, Aldy Hernandez wrote:
> >Yeah, the above is definitely wrong. Just
> > if (flag_cilkplus)
> > cpp_register_deferred_pragma (parse_in, NULL, "simd", PRAGMA_SIMD, true, false);
> Well, the thing is that you can't just use NULL for "#pragma simd"
> as a pragma and then define "#pragma simd assert" to use "simd" as a
> pragma namespace. I had already tried that:
My understanding is that the pragma is #pragma simd, it isn't a namespace,
and assert, vectorlength etc. are clauses.
#pragma simd [clause[ [,] clause]...]
Thus, you'd parse it as PRAGMA_SIMD, then you'd just parse all the
(optional) clauses for it.
Say for OpenMP 4.0 #pragma omp simd (which is IMHO different just by using
a non-NULL namespace). Upon seeing PRAGMA_OMP_SIMD (in your case
PRAGMA_SIMD), the C++ parser in cp_parser_pragma just calls a function to
handle parsing of it, for PRAGMA_OMP_SIMD on gomp-4_0-branch that is
cp_parser_omp_construct (after checking that the pragma doesn't appear
outside of function context (== pragma_external). That then just
calls cp_parser_omp_simd which uses a helper function
(cp_parser_omp_all_clauses) to parse the clauses and newline at the end
of the pragma line, then whatever else needs to be parsed after it (for