Author: abataev Date: Mon Apr 29 08:51:36 2019 New Revision: 359459 URL: http://llvm.org/viewvc/llvm-project?rev=359459&view=rev Log: [OPENMP]Fix PR41617: crash on template instantiation.
Fixed the crash on the template instantiation when trying to check the data locality in the current instantiation scope. Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp cfe/trunk/test/OpenMP/critical_ast_print.cpp Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=359459&r1=359458&r2=359459&view=diff ============================================================================== --- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original) +++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Mon Apr 29 08:51:36 2019 @@ -1145,7 +1145,7 @@ bool DSAStackTy::isOpenMPLocal(VarDecl * return false; TopScope = I->CurScope ? I->CurScope->getParent() : nullptr; Scope *CurScope = getCurScope(); - while (CurScope != TopScope && !CurScope->isDeclScope(D)) + while (CurScope && CurScope != TopScope && !CurScope->isDeclScope(D)) CurScope = CurScope->getParent(); return CurScope != TopScope; } Modified: cfe/trunk/test/OpenMP/critical_ast_print.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/critical_ast_print.cpp?rev=359459&r1=359458&r2=359459&view=diff ============================================================================== --- cfe/trunk/test/OpenMP/critical_ast_print.cpp (original) +++ cfe/trunk/test/OpenMP/critical_ast_print.cpp Mon Apr 29 08:51:36 2019 @@ -15,28 +15,46 @@ void foo() {} // CHECK: template <typename T, int N> int tmain(T argc, char **argv) // CHECK: static int a; // CHECK-NEXT: #pragma omp critical{{$}} -// CHECK-NEXT: a = 2; +// CHECK-NEXT: a = argv[0][0]; // CHECK-NEXT: ++a; +// CHECK-NEXT: #pragma omp critical{{$}} +// CHECK-NEXT: { +// CHECK-NEXT: int b = 10; +// CHECK-NEXT: T c = 100; +// CHECK-NEXT: a = b + c; +// CHECK-NEXT: } // CHECK-NEXT: #pragma omp critical (the_name) hint(N){{$}} // CHECK-NEXT: foo(); // CHECK-NEXT: return N; // CHECK: template<> int tmain<int, 4>(int argc, char **argv) template <typename T, int N> -int tmain (T argc, char **argv) { +int tmain(T argc, char **argv) { T b = argc, c, d, e, f, g; static int a; // CHECK: static int a; #pragma omp critical - a=2; -// CHECK-NEXT: #pragma omp critical -// CHECK-NEXT: a = 2; -// CHECK-NEXT: ++a; + a = argv[0][0]; ++a; -#pragma omp critical (the_name) hint(N) + // CHECK-NEXT: #pragma omp critical + // CHECK-NEXT: a = argv[0][0]; + // CHECK-NEXT: ++a; + // CHECK-NEXT: #pragma omp critical{{$}} + // CHECK-NEXT: { + // CHECK-NEXT: int b = 10; + // CHECK-NEXT: int c = 100; + // CHECK-NEXT: a = b + c; + // CHECK-NEXT: } +#pragma omp critical + { + int b = 10; + T c = 100; + a = b + c; + } +#pragma omp critical(the_name) hint(N) foo(); -// CHECK-NEXT: #pragma omp critical (the_name) hint(4) -// CHECK-NEXT: foo(); -// CHECK-NEXT: return 4; + // CHECK-NEXT: #pragma omp critical (the_name) hint(4) + // CHECK-NEXT: foo(); + // CHECK-NEXT: return 4; return N; } _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits