diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp --- a/clang/lib/Sema/SemaOpenMP.cpp +++ b/clang/lib/Sema/SemaOpenMP.cpp @@ -7239,6 +7239,10 @@ if (!CalleeFnDecl) return Call; + // Scope can be nullptr here if any compile error is encountered before. + if (!Scope) + return Call; + if (LangOpts.OpenMP >= 51 && CalleeFnDecl->getIdentifier() && CalleeFnDecl->getName().startswith_insensitive("omp_")) { // checking for any calls inside an Order region diff --git a/clang/test/OpenMP/bug59944.c b/clang/test/OpenMP/bug59944.c new file mode 100644 --- /dev/null +++ b/clang/test/OpenMP/bug59944.c @@ -0,0 +1,10 @@ +// RUN: %clang_cc1 -fopenmp -fopenmp-version=52 -x c -triple x86_64-apple-darwin10 %s -o - 2>&1 | FileCheck %s --check-prefix=CHECK + +extern void *omp_get_mapped_ptr(void *, int); + +void t() { + omp_get_mapped_ptr(&x, omp_get_initial_device()); +} + +// CHECK: error: use of undeclared identifier 'x' +// CHECK-NOT: crash