Skip to content

Commit a6fad01

Browse files
committed
fix the driver so the test passes
1 parent 9fc5095 commit a6fad01

File tree

1 file changed

+33
-61
lines changed

1 file changed

+33
-61
lines changed

flang/test/Lower/end-to-end-character-assignment-driver.cpp

Lines changed: 33 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,8 @@ struct Fchar {
2626
LenT len;
2727
};
2828

29-
template <typename... T> using SubF18 = void (*)(Fchar, Fchar, T...);
30-
template <typename... T>
31-
using SubF77 = void (*)(char *, char *, T..., LenT, LenT);
32-
template <typename... T>
33-
void CallSubroutine(SubF18<T...> f, Fchar s1, Fchar s2, T... args) {
34-
f(s1, s2, args...);
35-
}
36-
37-
template <typename... T>
38-
void CallSubroutine(SubF77<T...> f, Fchar s1, Fchar s2, T... args) {
29+
template <typename F, typename... T>
30+
void CallSubroutine(F f, Fchar s1, Fchar s2, T... args) {
3931
f(s1.data, s2.data, args..., s1.len, s2.len);
4032
}
4133

@@ -113,29 +105,9 @@ bool Check(const FcharData<Kind> &test, const FcharData<Kind> &ref,
113105
return true;
114106
}
115107

116-
// Call compiled test subroutine and compare variable afterwards with a
117-
// reference. Compare against result from reference subroutine.
118-
template <int Kind, typename... T>
119-
bool TestSubroutine(const std::string &testName, SubF18<T...> fooTest,
120-
SubF18<T...> fooRef, const FcharData<Kind> &s1, const FcharData<Kind> &s2,
121-
T... otherArgs) {
122-
// Make copies because data may be modified
123-
FcharData<Kind> testS1{s1}, testS2{s2};
124-
CallSubroutine(fooTest, testS1.getFchar(), testS2.getFchar(), otherArgs...);
125-
126-
// Compare against reference subroutine
127-
FcharData<Kind> refS1{s1}, refS2{s2};
128-
CallSubroutine(fooRef, refS1.getFchar(), refS2.getFchar(), otherArgs...);
129-
130-
auto description{testName + " KIND=" + std::to_string(Kind)};
131-
bool result{Check(testS1, refS1, description + " s1")};
132-
result &= Check(testS2, refS2, description + " s2");
133-
return result;
134-
}
135-
136108
// Compare against precomputed results.
137-
template <int Kind, typename... T>
138-
bool TestSubroutine(const std::string &testName, SubF18<T...> fooTest,
109+
template <int Kind, typename F, typename... T>
110+
bool TestSubroutine(const std::string &testName, F fooTest,
139111
const FcharData<Kind> &s1, const FcharData<Kind> &refS1,
140112
const FcharData<Kind> &s2, const FcharData<Kind> &refS2, T... otherArgs) {
141113
// Make copies because data may be modified
@@ -176,13 +148,13 @@ extern "C" {
176148
// CHARACTER(*, K) :: s1, s2
177149
// s1 = s2
178150
// END SUBROUTINE
179-
void _QPassign1(Fchar, Fchar);
180-
void _QPassign2(Fchar, Fchar);
181-
void _QPassign4(Fchar, Fchar);
151+
void _QPassign1(char *, char *, LenT, LenT);
152+
void _QPassign2(char *, char *, LenT, LenT);
153+
void _QPassign4(char *, char *, LenT, LenT);
182154
}
183155

184156
template <int Kind, typename Func>
185-
void TestNormalAssignement(Func testedSub, int &tests, int &passed) {
157+
void TestNormalAssignment(Func testedSub, int &tests, int &passed) {
186158
auto &s1{Inputs<Kind>::s1};
187159
auto &s2{Inputs<Kind>::s2};
188160
auto &s3{Inputs<Kind>::s3};
@@ -221,13 +193,13 @@ extern "C" {
221193
// INTEGER :: lb, ub
222194
// s1(lb:ub) = s2
223195
// END SUBROUTINE
224-
void _QPassign_substring1(Fchar s1, Fchar s2, int *lb, int *ub);
225-
void _QPassign_substring2(Fchar, Fchar, int *, int *);
226-
void _QPassign_substring4(Fchar, Fchar, int *, int *);
196+
void _QPassign_substring1(char *s1, char *s2, int *lb, int *ub, LenT, LenT);
197+
void _QPassign_substring2(char *, char *, int *, int *, LenT, LenT);
198+
void _QPassign_substring4(char *, char *, int *, int *, LenT, LenT);
227199
}
228200

229201
template <int Kind, typename Func>
230-
void TestSubstringAssignement(Func testedSub, int &tests, int &passed) {
202+
void TestSubstringAssignment(Func testedSub, int &tests, int &passed) {
231203
auto &s1{Inputs<Kind>::s3};
232204
auto &s2{Inputs<Kind>::s1};
233205
int lb{3};
@@ -257,13 +229,13 @@ extern "C" {
257229
// INTEGER :: lb
258230
// s1(lb:) = s2
259231
// END SUBROUTINE
260-
void _QPassign_overlap1(Fchar s1, Fchar s2, int *lb);
261-
void _QPassign_overlap2(Fchar, Fchar, int *);
262-
void _QPassign_overlap4(Fchar, Fchar, int *);
232+
void _QPassign_overlap1(char *s1, char *s2, int *lb, LenT, LenT);
233+
void _QPassign_overlap2(char *, char *, int *, LenT, LenT);
234+
void _QPassign_overlap4(char *, char *, int *, LenT, LenT);
263235
}
264236

265237
template <int Kind, typename Func>
266-
void TestOverlappingAssignement(Func testedSub, int &tests, int &passed) {
238+
void TestOverlappingAssignment(Func testedSub, int &tests, int &passed) {
267239
auto &s1{Inputs<Kind>::s1};
268240
auto &s2{Inputs<Kind>::s2};
269241
int lb{2};
@@ -290,13 +262,13 @@ extern "C" {
290262
// CHARACTER(l2, K) :: s2
291263
// s1 = s2
292264
// END SUBROUTINE
293-
void _QPassign_spec_expr_len1(Fchar s1, Fchar s2, int *l1, int *l2);
294-
void _QPassign_spec_expr_len2(Fchar s1, Fchar s2, int *l1, int *l2);
295-
void _QPassign_spec_expr_len4(Fchar s1, Fchar s2, int *l1, int *l2);
265+
void _QPassign_spec_expr_len1(char *s1, char *s2, int *l1, int *l2, LenT, LenT);
266+
void _QPassign_spec_expr_len2(char *s1, char *s2, int *l1, int *l2, LenT, LenT);
267+
void _QPassign_spec_expr_len4(char *s1, char *s2, int *l1, int *l2, LenT, LenT);
296268
}
297269

298270
template <int Kind, typename Func>
299-
void TestSpecExprLenAssignement(Func testedSub, int &tests, int &passed) {
271+
void TestSpecExprLenAssignment(Func testedSub, int &tests, int &passed) {
300272
auto &s1{Inputs<Kind>::s1};
301273
auto &s2{Inputs<Kind>::s2};
302274
auto &s3{Inputs<Kind>::s3};
@@ -339,7 +311,7 @@ extern "C" {
339311
// CHARACTER(*) :: s1, s2
340312
// s2 = s1 // " another piece of string"
341313
// END SUBROUTINE
342-
void _QPconcat1(Fchar s1, Fchar s2);
314+
void _QPconcat1(char *s1, char *s2, LenT, LenT);
343315
}
344316

345317
template <int Kind, typename Func>
@@ -360,21 +332,21 @@ void TestConcat(Func testedSub, int &tests, int &passed) {
360332
int main(int, char **) {
361333
int tests{0}, passed{0};
362334

363-
TestNormalAssignement<1>(_QPassign1, tests, passed);
364-
TestNormalAssignement<2>(_QPassign2, tests, passed);
365-
TestNormalAssignement<4>(_QPassign4, tests, passed);
335+
TestNormalAssignment<1>(_QPassign1, tests, passed);
336+
TestNormalAssignment<2>(_QPassign2, tests, passed);
337+
TestNormalAssignment<4>(_QPassign4, tests, passed);
366338

367-
TestSubstringAssignement<1>(_QPassign_substring1, tests, passed);
368-
TestSubstringAssignement<2>(_QPassign_substring2, tests, passed);
369-
TestSubstringAssignement<4>(_QPassign_substring4, tests, passed);
339+
TestSubstringAssignment<1>(_QPassign_substring1, tests, passed);
340+
TestSubstringAssignment<2>(_QPassign_substring2, tests, passed);
341+
TestSubstringAssignment<4>(_QPassign_substring4, tests, passed);
370342

371-
TestOverlappingAssignement<1>(_QPassign_overlap1, tests, passed);
372-
TestOverlappingAssignement<2>(_QPassign_overlap2, tests, passed);
373-
TestOverlappingAssignement<4>(_QPassign_overlap4, tests, passed);
343+
TestOverlappingAssignment<1>(_QPassign_overlap1, tests, passed);
344+
TestOverlappingAssignment<2>(_QPassign_overlap2, tests, passed);
345+
TestOverlappingAssignment<4>(_QPassign_overlap4, tests, passed);
374346

375-
TestSpecExprLenAssignement<1>(_QPassign_spec_expr_len1, tests, passed);
376-
TestSpecExprLenAssignement<2>(_QPassign_spec_expr_len2, tests, passed);
377-
TestSpecExprLenAssignement<4>(_QPassign_spec_expr_len4, tests, passed);
347+
TestSpecExprLenAssignment<1>(_QPassign_spec_expr_len1, tests, passed);
348+
TestSpecExprLenAssignment<2>(_QPassign_spec_expr_len2, tests, passed);
349+
TestSpecExprLenAssignment<4>(_QPassign_spec_expr_len4, tests, passed);
378350

379351
TestConcat<1>(_QPconcat1, tests, passed);
380352

0 commit comments

Comments
 (0)