]> granicus.if.org Git - clang/commitdiff
[OPENMP]Fix parsing/sema for function templates with declare simd.
authorAlexey Bataev <a.bataev@hotmail.com>
Mon, 16 Sep 2019 17:06:31 +0000 (17:06 +0000)
committerAlexey Bataev <a.bataev@hotmail.com>
Mon, 16 Sep 2019 17:06:31 +0000 (17:06 +0000)
Need to return original declaration group with FunctionTemplateDecl, not
the inner FunctionDecl, to correctly handle parsing of directives with
the templates parameters.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@372011 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaOpenMP.cpp
test/OpenMP/declare_simd_ast_print.cpp

index 97844cd57056c592ac0ad0f5f73fad22e2aeb937..ef2ef8b261a94ee08afbc34b694422a9fce394a1 100644 (file)
@@ -4889,7 +4889,7 @@ Sema::DeclGroupPtrTy Sema::ActOnOpenMPDeclareSimdDirective(
       const_cast<unsigned *>(LinModifiers.data()), LinModifiers.size(),
       NewSteps.data(), NewSteps.size(), SR);
   ADecl->addAttr(NewAttr);
-  return ConvertDeclToDeclGroup(ADecl);
+  return DG;
 }
 
 Sema::DeclGroupPtrTy
index c09f8b42e6d53e817f41cb9e8980e8cbc19adb11..565dc2dfc04d118ab66fc9424105ba243f41f25f 100644 (file)
@@ -21,6 +21,15 @@ void add_1(float *d) __attribute__((cold));
 // CHECK-NEXT: void add_1(float *d) __attribute__((cold));
 //
 
+#pragma omp declare simd aligned(hp, hp2:V)
+#pragma omp declare simd aligned(hp, hp2:V)
+template <class C, int V> void h(C *hp, C *hp2, C *hq, C *lin) {
+}
+// CHECK-NEXT: #pragma omp declare simd aligned(hp: V) aligned(hp2: V)
+// CHECK-NEXT: #pragma omp declare simd aligned(hp: V) aligned(hp2: V)
+// CHECK-NEXT: template <class C, int V> void h(C *hp, C *hp2, C *hq, C *lin) {
+// CHECK-NEXT: }
+
 #pragma omp declare simd aligned(hp, hp2)
 template <class C> void h(C *hp, C *hp2, C *hq, C *lin) {
 }