From a00630785fc7bbc723950543b0d82b6a70bfc797 Mon Sep 17 00:00:00 2001 From: Alexey Bataev Date: Mon, 16 Sep 2019 17:06:31 +0000 Subject: [PATCH] [OPENMP]Fix parsing/sema for function templates with declare simd. Need to return original declaration group with FunctionTemplateDecl, not the inner FunctionDecl, to correctly handle parsing of directives with the templates parameters. llvm-svn: 372011 --- clang/lib/Sema/SemaOpenMP.cpp | 2 +- clang/test/OpenMP/declare_simd_ast_print.cpp | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp index 97844cd57056..ef2ef8b261a9 100644 --- a/clang/lib/Sema/SemaOpenMP.cpp +++ b/clang/lib/Sema/SemaOpenMP.cpp @@ -4889,7 +4889,7 @@ Sema::DeclGroupPtrTy Sema::ActOnOpenMPDeclareSimdDirective( const_cast(LinModifiers.data()), LinModifiers.size(), NewSteps.data(), NewSteps.size(), SR); ADecl->addAttr(NewAttr); - return ConvertDeclToDeclGroup(ADecl); + return DG; } Sema::DeclGroupPtrTy diff --git a/clang/test/OpenMP/declare_simd_ast_print.cpp b/clang/test/OpenMP/declare_simd_ast_print.cpp index c09f8b42e6d5..565dc2dfc04d 100644 --- a/clang/test/OpenMP/declare_simd_ast_print.cpp +++ b/clang/test/OpenMP/declare_simd_ast_print.cpp @@ -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 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 void h(C *hp, C *hp2, C *hq, C *lin) { +// CHECK-NEXT: } + #pragma omp declare simd aligned(hp, hp2) template void h(C *hp, C *hp2, C *hq, C *lin) { }