[PATCH] Fix use of declare'd vars by routine procedures.

James Norris jnorris@codesourcery.com
Mon Feb 1 16:00:00 GMT 2016


Hi!

On 01/29/2016 02:31 AM, Jakub Jelinek wrote:
> On Thu, Jan 28, 2016 at 12:26:38PM -0600, James Norris wrote:
>> I think the attached change is what you had in mind with
>> regard to doing the check at gimplification time.
>
> Nope, this is still a wrong location for that.
> If you look at the next line after the block you've added, you'll see
> if (gimplify_omp_ctxp && omp_notice_variable (gimplify_omp_ctxp, decl, true))
> And that function fairly early calls is_global_var (decl).  So you know
> already gimplify_omp_ctxp && is_global_var (decl), just put the rest into
> that block.

When said you said "rest into that block", I assumed you meant
the block in omp_notice_variable () that has the function call
to is_global_var () as the if condition.

> The TREE_CODE (decl) == VAR_DECL check is VAR_P (decl).

Fixed.

> What do you want to achieve with
>
>> +      && ((TREE_STATIC (decl) && !DECL_EXTERNAL (decl))
>> +       || (!TREE_STATIC (decl) && DECL_EXTERNAL (decl))))
>
> ?  is_global_var already guarantees you that it is either TREE_STATIC
> or DECL_EXTERNAL, why is that not good enough?

As you pointed out above, the check is not necessary.

>
>> [snip snip]
>>
>> +  /* Validate variable for use within routine function.  */
>> +  if (gimplify_omp_ctxp && gimplify_omp_ctxp->region_type == ORT_TARGET
>> +      && get_oacc_fn_attrib (current_function_decl)
>
> If you only care about the implicit target region of acc routine, I think
> you also want to check that gimplify_omp_ctxp->outer_context == NULL.

Check added.

>
>> [snip snip]
>
> And I'm really confused by this error message.  If you are complaining that
> the variable is not listed in acc declare clauses, why don't you say that?
> What does the error have to do with its storage class?
> Also, splitting one error into two is weird, usually there would be one
> error message and perhaps inform after it.

Error messages re-written to make better sense.

Thanks!

Jim

===== ChangeLog entries....

         gcc/
         * gimplify.c (omp_notice_variable): Add variable usage check.
         gcc/testsuite/
         * c-c++-common/goacc/routine-5.c: Add tests.



-------------- next part --------------
A non-text attachment was scrubbed...
Name: declare.patch
Type: text/x-patch
Size: 4452 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20160201/3b42ba85/attachment.bin>


More information about the Gcc-patches mailing list