From: Alexey Bataev Date: Mon, 30 Apr 2018 18:09:40 +0000 (+0000) Subject: [OPENMP] Do not crash on codegen for CXX member functions. X-Git-Tag: llvmorg-7.0.0-rc1~7065 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=dadf2d1238f1ad619fb020f3172162a7d34a2180;p=platform%2Fupstream%2Fllvm.git [OPENMP] Do not crash on codegen for CXX member functions. Non-static member functions should not be emitted as a standalone functions, this leads to compiler crash. llvm-svn: 331206 --- diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp b/clang/lib/CodeGen/CGOpenMPRuntime.cpp index 33dfe71..0500f23 100644 --- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp +++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp @@ -898,6 +898,9 @@ static void EmitOMPAggregateInit(CodeGenFunction &CGF, Address DestAddr, static llvm::Optional isDeclareTargetDeclaration(const ValueDecl *VD) { + if (const auto *MD = dyn_cast(VD)) + if (!MD->isStatic()) + return llvm::None; for (const Decl *D : VD->redecls()) { if (!D->hasAttrs()) continue; diff --git a/clang/test/OpenMP/declare_target_codegen.cpp b/clang/test/OpenMP/declare_target_codegen.cpp index 86c0c02..a5a51bc 100644 --- a/clang/test/OpenMP/declare_target_codegen.cpp +++ b/clang/test/OpenMP/declare_target_codegen.cpp @@ -32,6 +32,11 @@ int baz2(); int baz4() { return 5; } #pragma omp declare target +struct S { + int a; + S(int a) : a(a) {} +}; + int foo() { return 0; } int b = 15; int d; @@ -47,6 +52,7 @@ int maini1() { #pragma omp target map(tofrom \ : a, b) { + S s(a); static long aaa = 23; a = foo() + bar() + b + c + d + aa + aaa; }