Author: Alexey Bataev Date: 2020-11-12T13:26:11-08:00 New Revision: 07b568a9c8db8e5d4d4af4c766ecfb38145fb0bf
URL: https://github.com/llvm/llvm-project/commit/07b568a9c8db8e5d4d4af4c766ecfb38145fb0bf DIFF: https://github.com/llvm/llvm-project/commit/07b568a9c8db8e5d4d4af4c766ecfb38145fb0bf.diff LOG: [OPENMP]Fix PR47790: segfault in frontend while parsing Objective-C with OpenMP. Need to check if the sema is actually finishing a function decl. Differential Revision: https://reviews.llvm.org/D91376 Added: clang/test/SemaObjCXX/objcxx_openmp.mm Modified: clang/lib/Sema/SemaDecl.cpp Removed: ################################################################################ diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 4f054e9f1ebf..3b940a017a02 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -14598,7 +14598,7 @@ Decl *Sema::ActOnFinishFunctionBody(Decl *dcl, Stmt *Body, DiscardCleanupsInEvaluationContext(); } - if (LangOpts.OpenMP || LangOpts.CUDA || LangOpts.SYCLIsDevice) { + if (FD && (LangOpts.OpenMP || LangOpts.CUDA || LangOpts.SYCLIsDevice)) { auto ES = getEmissionStatus(FD); if (ES == Sema::FunctionEmissionStatus::Emitted || ES == Sema::FunctionEmissionStatus::Unknown) diff --git a/clang/test/SemaObjCXX/objcxx_openmp.mm b/clang/test/SemaObjCXX/objcxx_openmp.mm new file mode 100644 index 000000000000..a789e2a83709 --- /dev/null +++ b/clang/test/SemaObjCXX/objcxx_openmp.mm @@ -0,0 +1,22 @@ +// RUN: %clang_cc1 -fopenmp -fsyntax-only -verify %s +// expected-no-diagnostics + +class Foo { + int a; +}; + +@interface NSObject +@end + +@interface Bar : NSObject { + Foo *foo; +} +- (void)setSystemAndWindowCocoa:(class Foo *)foo_1; + +@end + +@implementation Bar : NSObject +- (void)setSystemAndWindowCocoa:(Foo *)foo_1 { + foo = foo_1; +} +@end _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits