From 8035bb4a6573f7d20f17044a68a1405691000525 Mon Sep 17 00:00:00 2001 From: Alexey Bataev Date: Fri, 13 Dec 2019 16:05:30 -0500 Subject: [OPENMP]Fix skipping of functions body. When parsing the code with OpenMP and the function's body must be skipped, need to skip also OpenMP annotation tokens. Otherwise the counters for braces/parens are unbalanced and parsing fails. --- .../OpenMP/crash-skipped-bodies-template-inst.cpp | 30 ++++++++++++++++++++++ clang/test/OpenMP/openmp_check.cpp | 10 -------- 2 files changed, 30 insertions(+), 10 deletions(-) create mode 100644 clang/test/OpenMP/crash-skipped-bodies-template-inst.cpp (limited to 'clang/test/OpenMP') diff --git a/clang/test/OpenMP/crash-skipped-bodies-template-inst.cpp b/clang/test/OpenMP/crash-skipped-bodies-template-inst.cpp new file mode 100644 index 00000000000..c7ba432d509 --- /dev/null +++ b/clang/test/OpenMP/crash-skipped-bodies-template-inst.cpp @@ -0,0 +1,30 @@ +// RUN: not %clang_cc1 -fsyntax-only -std=c++14 -code-completion-at=%s:28:5 -fopenmp %s -o - 2>&1 | FileCheck %s +template +auto make_func() { + struct impl { + impl* func() { + int x; + if (x = 10) { + #pragma omp parallel + ; + } + // Check that body of this function is actually skipped. + // CHECK-NOT: crash-skipped-bodies-template-inst.cpp:7:{{[0-9]+}}: warning: using the result of an assignment as a condition without parentheses + return this; + } + }; + + int x; + if (x = 10) {} + // Check that this function is not skipped. + // CHECK: crash-skipped-bodies-template-inst.cpp:18:9: warning: using the result of an assignment as a condition without parentheses + return impl(); +} + +void foo() { + []() { + make_func(); + m + // CHECK: COMPLETION: make_func : [#auto#]make_func<<#class T#>>() + }; +} diff --git a/clang/test/OpenMP/openmp_check.cpp b/clang/test/OpenMP/openmp_check.cpp index cd4706b57e4..6a8dd17fc83 100644 --- a/clang/test/OpenMP/openmp_check.cpp +++ b/clang/test/OpenMP/openmp_check.cpp @@ -19,7 +19,6 @@ int nested(int a) { #if __cplusplus <= 199711L // expected-warning@-2 {{'auto' type specifier is a C++11 extension}} // expected-error@-3 {{expected expression}} - // expected-error@-4 {{expected ';' at end of declaration}} #endif #pragma omp parallel @@ -29,14 +28,5 @@ int nested(int a) { } }; F(); -#if __cplusplus <= 199711L - // expected-error@-2 {{C++ requires a type specifier for all declarations}} -#endif return a; -#if __cplusplus <= 199711L - // expected-error@-2 {{expected unqualified-id}} -#endif } -#if __cplusplus <= 199711L -// expected-error@-2 {{extraneous closing brace ('}')}} -#endif -- cgit v1.2.3