ABataev added a comment.


In D74144#2307454 <https://reviews.llvm.org/D74144#2307454>, @cchen wrote:

> @ABataev, the below test is extracted from Sollve test suite and Clang now 
> emit:
>
>   test.c:17:35: error: subscripted value is not an array or pointer
>       #pragma omp target update to( (([N][N])foo)[1:M] )
>                                     ^~~~~~~~~~~~~
>   test.c:17:5: error: expected at least one 'to' clause or 'from' clause 
> specified to '#pragma omp target update'
>       #pragma omp target update to( (([N][N])foo)[1:M] )
>
> This error message came from the `ActOnOMPArraySectionExpr` which is called 
> inside `ParsePostfixExpressionSuffix`. The issue is that the base expression 
> in `ActOnOMPArraySectionExpr` looks like:
>
>   ParenExpr 0x122859be0 '<OpenMP array shaping type>' lvalue
>   `-OMPArrayShapingExpr 0x122859b98 '<OpenMP array shaping type>' lvalue
>     |-IntegerLiteral 0x122859b38 'int' 5
>     |-IntegerLiteral 0x122859b58 'int' 5
>     `-DeclRefExpr 0x122859b78 'int *' lvalue Var 0x1228599d0 'foo' 'int *'
>
> which is not a base that we would expect in an array section expr. I've tried 
> relaxing the base type check in `ActOnOMPArraySectionExpr` but not sure it's 
> the way to go. (or should I just extract the DeclReExpr from ArrayShapingExpr 
> before calling `ActOnOMPArraySectionExpr`?)
>
>   #define N 5
>   #define M 3
>   
>   int main(void) {
>       int tmp[N][N];
>       for(int i=0; i<N; i++)
>           for(int j=0; j<N; j++)
>               tmp[i][j] = N*i + j;
>   
>       int *foo = &tmp[0][0];
>   
>       // This compiles just fine
>       //#pragma omp target update to( ([N][N])foo )
>   
>       // This is rejected by the compiler
>       #pragma omp target update to( (([N][N])foo)[1:M] )
>   }

I don't think it is allowed by the standard.

According to the standard, The shape-operator can appear only in clauses where 
it is explicitly allowed.
In this case, array shaping is used as a base expression of array section (or 
subscript) expression, which does not meet the standard. Tje array sjaping 
operation is not used in clause, instead it is used as a base subexpression of 
another expression.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D74144/new/

https://reviews.llvm.org/D74144

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to