[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
This commit is contained in:
Alexey Bataev 2020-11-12 11:42:30 -08:00
parent 9c504ec06d
commit 07b568a9c8
2 changed files with 23 additions and 1 deletions

View File

@ -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)

View File

@ -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