Author: Alexey Bataev
Date: 2020-01-07T09:28:50-05:00
New Revision: 3f2e3dc44b42fab2e991222e74248b7006f1091e

URL: 
https://github.com/llvm/llvm-project/commit/3f2e3dc44b42fab2e991222e74248b7006f1091e
DIFF: 
https://github.com/llvm/llvm-project/commit/3f2e3dc44b42fab2e991222e74248b7006f1091e.diff

LOG: [OPENMP]Do not diagnose references to non-integral types for ref in
declare simd.

According to the standard, a list-item that appears in a linear clause without 
the ref modifier must be of integral or pointer type, or must be a reference to 
an integral or pointer type. Added check that this restriction is applied only 
to non-ref items.

Added: 
    

Modified: 
    clang/lib/Sema/SemaOpenMP.cpp
    clang/test/OpenMP/declare_simd_messages.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index d2393c17bcc8..9298a7f0d645 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -14354,8 +14354,8 @@ bool Sema::CheckOpenMPLinearDecl(const ValueDecl *D, 
SourceLocation ELoc,
   // A list item must be of integral or pointer type.
   Type = Type.getUnqualifiedType().getCanonicalType();
   const auto *Ty = Type.getTypePtrOrNull();
-  if (!Ty || (!Ty->isDependentType() && !Ty->isIntegralType(Context) &&
-              !Ty->isPointerType())) {
+  if (!Ty || (LinKind != OMPC_LINEAR_ref && !Ty->isDependentType() &&
+              !Ty->isIntegralType(Context) && !Ty->isPointerType())) {
     Diag(ELoc, diag::err_omp_linear_expected_int_or_ptr) << Type;
     if (D) {
       bool IsDecl =

diff  --git a/clang/test/OpenMP/declare_simd_messages.cpp 
b/clang/test/OpenMP/declare_simd_messages.cpp
index d5451aba4f80..44cf41541f50 100644
--- a/clang/test/OpenMP/declare_simd_messages.cpp
+++ b/clang/test/OpenMP/declare_simd_messages.cpp
@@ -197,7 +197,8 @@ void test() {
 #pragma omp declare simd linear(ref(b))
 // expected-error@+1 {{expected one of 'ref', val' or 'uval' modifiers}} 
expected-warning@+1 {{extra tokens at the end of '#pragma omp declare simd' are 
ignored}}
 #pragma omp declare simd linear(uref(b)) allocate(b)
-void bar(int a, int *b);
+#pragma omp declare simd linear(ref(c))
+void bar(int a, int *b, float &c);
 
 template <class T>
 struct St {


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

Reply via email to