Skip to content

Commit 07b568a

Browse files
committed
[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
1 parent 9c504ec commit 07b568a

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

clang/lib/Sema/SemaDecl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14598,7 +14598,7 @@ Decl *Sema::ActOnFinishFunctionBody(Decl *dcl, Stmt *Body,
1459814598
DiscardCleanupsInEvaluationContext();
1459914599
}
1460014600

14601-
if (LangOpts.OpenMP || LangOpts.CUDA || LangOpts.SYCLIsDevice) {
14601+
if (FD && (LangOpts.OpenMP || LangOpts.CUDA || LangOpts.SYCLIsDevice)) {
1460214602
auto ES = getEmissionStatus(FD);
1460314603
if (ES == Sema::FunctionEmissionStatus::Emitted ||
1460414604
ES == Sema::FunctionEmissionStatus::Unknown)
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// RUN: %clang_cc1 -fopenmp -fsyntax-only -verify %s
2+
// expected-no-diagnostics
3+
4+
class Foo {
5+
int a;
6+
};
7+
8+
@interface NSObject
9+
@end
10+
11+
@interface Bar : NSObject {
12+
Foo *foo;
13+
}
14+
- (void)setSystemAndWindowCocoa:(class Foo *)foo_1;
15+
16+
@end
17+
18+
@implementation Bar : NSObject
19+
- (void)setSystemAndWindowCocoa:(Foo *)foo_1 {
20+
foo = foo_1;
21+
}
22+
@end

0 commit comments

Comments
 (0)