QualType AdjustedFnType = FD->getType();
if (NumAppendArgs) {
- if (isa<FunctionNoProtoType>(FD->getType())) {
+ const auto *PTy = AdjustedFnType->getAsAdjusted<FunctionProtoType>();
+ if (!PTy) {
Diag(FD->getLocation(), diag::err_omp_declare_variant_prototype_required)
<< SR;
return None;
Diag(SR.getBegin(), diag::err_omp_interop_type_not_found) << SR;
return None;
}
- QualType InteropType = QualType(TD->getTypeForDecl(), 0);
- auto *PTy = cast<FunctionProtoType>(FD->getType());
+ QualType InteropType = Context.getTypeDeclType(TD);
if (PTy->isVariadic()) {
Diag(FD->getLocation(), diag::err_omp_append_args_with_varargs) << SR;
return None;
--- /dev/null
+//RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=51 \
+//RUN: -Wno-source-uses-openmp -Wno-openmp-clauses \
+//RUN: -ast-print -o - %s | FileCheck %s --check-prefix=PRINT
+
+//RUN: %clang_cc1 -triple x86_64-pc-windows-msvc -fopenmp -fopenmp-version=51 \
+//RUN: -Wno-source-uses-openmp -Wno-openmp-clauses -DWIN -fms-compatibility \
+//RUN: -ast-print -o - %s | FileCheck %s --check-prefixes=PRINT,PRINTW
+
+//RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=51 \
+//RUN: -Wno-source-uses-openmp -Wno-openmp-clauses \
+//RUN: -ast-dump -o - %s | FileCheck %s --check-prefix=DUMP
+
+//RUN: %clang_cc1 -triple x86_64-pc-windows-msvc -fopenmp -fopenmp-version=51 \
+//RUN: -Wno-source-uses-openmp -Wno-openmp-clauses -DWIN -fms-compatibility \
+//RUN: -ast-dump -o - %s | FileCheck %s --check-prefixes=DUMP,DUMPW
+
+typedef void *omp_interop_t;
+
+#ifdef WIN
+//DUMPW: FunctionDecl{{.*}}win_foov
+//PRINTW: void win_foov(int n, double *y, void *interop_obj);
+
+void win_foov(int n, double *y, void *interop_obj);
+
+//DUMPW: FunctionDecl{{.*}}win_foo
+//DUMPW: OMPDeclareVariantAttr
+//DUMPW-NEXT: DeclRefExpr{{.*}}win_foov
+//PRINTW: #pragma omp declare variant(win_foov) match(construct={dispatch}, device={arch(x86_64)}) append_args(interop(targetsync))
+//PRINTW: void win_foo(int n, double *y);
+
+#pragma omp declare variant (win_foov) \
+ match(construct={dispatch}, device={arch(x86_64)}) \
+ append_args(interop(targetsync))
+void _cdecl win_foo(int n, double *y);
+#endif // WIN
+
+//DUMP: FunctionDecl{{.*}}c_foov
+//PRINT: void c_foov(int n, double *y, void *interop_obj);
+
+void c_foov(int n, double *y, void *interop_obj);
+
+//DUMP: FunctionDecl{{.*}}c_foo
+//DUMP: OMPDeclareVariantAttr
+//DUMP-NEXT: DeclRefExpr{{.*}}c_foov
+//PRINT: #pragma omp declare variant(c_foov) match(construct={dispatch}, device={arch(x86_64)}) append_args(interop(targetsync))
+//PRINT: void c_foo(int n, double *y);
+
+#pragma omp declare variant (c_foov) \
+ match(construct={dispatch}, device={arch(x86_64)}) \
+ append_args(interop(targetsync))
+void c_foo(int n, double *y);
// RUN: -DNO_INTEROP_T_DEF -o - %s
// RUN: %clang_cc1 -verify -triple x86_64-unknown-linux -fopenmp -fopenmp-version=50 -std=c++11 -o - %s
// RUN: %clang_cc1 -verify -triple x86_64-unknown-linux -fopenmp -fopenmp-version=51 -DC -x c -o - %s
+// RUN: %clang_cc1 -verify -triple x86_64-pc-windows-msvc -fms-compatibility \
+// RUN: -fopenmp -fopenmp-version=51 -DC -DWIN -x c -o - %s
#ifdef NO_INTEROP_T_DEF
void foo_v1(float *, void *);
#ifdef C
void c_variant(omp_interop_t);
// expected-error@+3 {{function with '#pragma omp declare variant' must have a prototype when 'append_args' is used}}
-#pragma omp declare variant(foo_v1) \
+#pragma omp declare variant(c_variant) \
append_args(interop(target)) match(construct={dispatch})
void c_base() {}
+#ifdef WIN
+void _cdecl win_c_variant(omp_interop_t);
+// expected-error@+3 {{function with '#pragma omp declare variant' must have a prototype when 'append_args' is used}}
+#pragma omp declare variant(win_c_variant) \
+ append_args(interop(target)) match(construct={dispatch})
+void _cdecl win_c_base() {}
+#endif // WIN
#endif