[OpenMP][Tools][NFC] Fix C99-style declaration of iteration variables
Where possible change to declare the variable before the loop.
Where not possible, specifically request -std=c99 (could be limited to
specific compilers like icc).
GitOrigin-RevId: 38f78dd2e25aa6ae9f9e2ffdef7a600391b791fe
diff --git a/runtime/test/lit.cfg b/runtime/test/lit.cfg
index dff693f..c1d240e 100644
--- a/runtime/test/lit.cfg
+++ b/runtime/test/lit.cfg
@@ -115,6 +115,8 @@
# substitutions
config.substitutions.append(("%libomp-compile-and-run", \
"%libomp-compile && %libomp-run"))
+config.substitutions.append(("%libomp-c99-compile-and-run", \
+ "%libomp-c99-compile && %libomp-run"))
config.substitutions.append(("%libomp-cxx-compile-and-run", \
"%libomp-cxx-compile && %libomp-run"))
config.substitutions.append(("%libomp-cxx-compile-c", \
@@ -123,6 +125,8 @@
"%clangXX %openmp_flags %flags -std=c++14 %s -o %t" + libs))
config.substitutions.append(("%libomp-compile", \
"%clang %openmp_flags %flags %s -o %t" + libs))
+config.substitutions.append(("%libomp-c99-compile", \
+ "%clang %openmp_flags %flags -std=c99 %s -o %t" + libs))
config.substitutions.append(("%libomp-run", "%t"))
config.substitutions.append(("%clangXX", config.test_cxx_compiler))
config.substitutions.append(("%clang", config.test_c_compiler))
diff --git a/runtime/test/ompt/callback.h b/runtime/test/ompt/callback.h
index 2e9c057..2abab37 100644
--- a/runtime/test/ompt/callback.h
+++ b/runtime/test/ompt/callback.h
@@ -1033,7 +1033,8 @@
{
char buffer[2048];
char *progress = buffer;
- for (int i = 0; i < ndeps && progress < buffer + 2000; i++) {
+ int i;
+ for (i = 0; i < ndeps && progress < buffer + 2000; i++) {
if (deps[i].dependence_type == ompt_dependence_type_source ||
deps[i].dependence_type == ompt_dependence_type_sink)
progress +=
diff --git a/runtime/test/ompt/synchronization/ordered_dependences.c b/runtime/test/ompt/synchronization/ordered_dependences.c
index c3c6471..5b7d565 100644
--- a/runtime/test/ompt/synchronization/ordered_dependences.c
+++ b/runtime/test/ompt/synchronization/ordered_dependences.c
@@ -1,4 +1,4 @@
-// RUN: %libomp-compile-and-run | %sort-threads | FileCheck %s
+// RUN: %libomp-c99-compile-and-run | %sort-threads | FileCheck %s
// REQUIRES: ompt
// UNSUPPORTED: gcc-4, gcc-5, gcc-6, gcc-7
#include "callback.h"
diff --git a/runtime/test/worksharing/for/omp_par_in_loop.c b/runtime/test/worksharing/for/omp_par_in_loop.c
index d80de5d..6074c45 100644
--- a/runtime/test/worksharing/for/omp_par_in_loop.c
+++ b/runtime/test/worksharing/for/omp_par_in_loop.c
@@ -1,4 +1,4 @@
-// RUN: %libomp-compile-and-run
+// RUN: %libomp-c99-compile-and-run
//
#include <stdlib.h>
#include <stdio.h>