diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -14598,7 +14598,7 @@ 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 --- /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