[OPENMP 4.0] Parsing/sema analysis for 'simdlen' clause in 'declare simd'
construct.

OpenMP 4.0 defines '#pragma omp declare simd' construct that may have
associated 'simdlen' clause with constant positive expression as an
argument:
simdlen(<const_expr>)
Patch adds parsin and semantic analysis for simdlen clause.

llvm-svn: 265668
diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 0ef7965..3705cf2 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -3193,7 +3193,7 @@
 Sema::DeclGroupPtrTy
 Sema::ActOnOpenMPDeclareSimdDirective(DeclGroupPtrTy DG,
                                       OMPDeclareSimdDeclAttr::BranchStateTy BS,
-                                      SourceRange SR) {
+                                      Expr *Simdlen, SourceRange SR) {
   if (!DG || DG.get().isNull())
     return DeclGroupPtrTy();
 
@@ -3211,7 +3211,17 @@
     return DeclGroupPtrTy();
   }
 
-  auto *NewAttr = OMPDeclareSimdDeclAttr::CreateImplicit(Context, BS, SR);
+  // OpenMP [2.8.2, declare simd construct, Description]
+  // The parameter of the simdlen clause must be a constant positive integer
+  // expression.
+  ExprResult SL;
+  if (Simdlen) {
+    SL = VerifyPositiveIntegerConstantInClause(Simdlen, OMPC_simdlen);
+    if (SL.isInvalid())
+      return DG;
+  }
+  auto *NewAttr =
+      OMPDeclareSimdDeclAttr::CreateImplicit(Context, BS, SL.get(), SR);
   ADecl->addAttr(NewAttr);
   return ConvertDeclToDeclGroup(ADecl);
 }