diff --git a/clang/lib/AST/StmtPrinter.cpp b/clang/lib/AST/StmtPrinter.cpp index f08e3a3a9b13..173b5c7fcfa5 100644 --- a/clang/lib/AST/StmtPrinter.cpp +++ b/clang/lib/AST/StmtPrinter.cpp @@ -1300,9 +1300,11 @@ void StmtPrinter::VisitOMPArraySectionExpr(OMPArraySectionExpr *Node) { OS << "["; if (Node->getLowerBound()) PrintExpr(Node->getLowerBound()); - OS << ":"; - if (Node->getLength()) - PrintExpr(Node->getLength()); + if (Node->getColonLoc().isValid()) { + OS << ":"; + if (Node->getLength()) + PrintExpr(Node->getLength()); + } OS << "]"; } diff --git a/clang/test/OpenMP/task_ast_print.cpp b/clang/test/OpenMP/task_ast_print.cpp index c87dbdd5ead9..dae967e25410 100644 --- a/clang/test/OpenMP/task_ast_print.cpp +++ b/clang/test/OpenMP/task_ast_print.cpp @@ -87,8 +87,8 @@ int main(int argc, char **argv) { #pragma omp threadprivate(a) Enum ee; // CHECK: Enum ee; -#pragma omp task untied mergeable depend(out:argv[1], (arr)[0:]) if(task: argc > 0) - // CHECK-NEXT: #pragma omp task untied mergeable depend(out : argv[1],(arr)[0:]) if(task: argc > 0) +#pragma omp task untied mergeable depend(out:argv[:a][1], (arr)[0:]) if(task: argc > 0) + // CHECK-NEXT: #pragma omp task untied mergeable depend(out : argv[:a][1],(arr)[0:]) if(task: argc > 0) a = 2; // CHECK-NEXT: a = 2; #pragma omp task default(none), private(argc, b) firstprivate(argv) if (argc > 0) final(a > 0) depend(inout : a, argv[:argc],arr[:a])