Polly 20.0.0git
isl_test_cpp-checked-conversion.cc
Go to the documentation of this file.
1/*
2 * Copyright 2018 Sven Verdoolaege
3 *
4 * Use of this software is governed by the MIT license
5 *
6 * Written by Sven Verdoolaege.
7 */
8
9#include <stdlib.h>
10
11#include <isl/ctx.h>
12#include <isl/options.h>
13#include <isl/cpp-checked-conversion.h>
14
15/* Check that converting a NULL object from the checked C++ bindings
16 * (where the user is expected to check for NULL return values)
17 * to the default C++ bindings (where exceptions are raised
18 * instead of returning a NULL object) raises an exception.
19 */
21{
22 isl::checked::set checked_set;
24
25 bool caught = false;
26 try {
27 set = isl::uncheck(checked_set);
28 isl_die(ctx, isl_error_unknown, "no exception raised", return);
29 } catch (const isl::exception &e) {
30 caught = true;
31 }
32 if (!caught)
33 isl_die(ctx, isl_error_unknown, "no exception raised", return);
34}
35
36/* Dummy function on a set in the checked C++ bindings.
37 */
38static void f_checked(isl::checked::set set)
39{
40}
41
42/* Dummy function on a set in the default C++ bindings.
43 */
45{
46}
47
48/* Check the conversion between C++ bindings in function calls.
49 * An incorrect call will result in a compiler error.
50 */
52{
53 isl::set set(ctx, "{ S[i] : 0 <= i < 10 }");
54 isl::checked::set checked_set(ctx, "{ S[i] : 0 <= i < 10 }");
55
57 f_checked(isl::check(set));
58 f_unchecked(isl::uncheck(checked_set));
59 f_checked(checked_set);
60}
61
62/* Check that a double conversion results in the original set,
63 * or at least something that is equal to the original set.
64 */
66{
67 isl::set set(ctx, "{ S[i] : 0 <= i < 10 }");
69 isl::checked::set checked_set;
70
71 checked_set = isl::check(set);
72 set2 = isl::uncheck(checked_set);
73
74 if (!set.is_equal(set2))
75 isl_die(ctx, isl_error_unknown, "bad conversion", return);
76}
77
78/* Perform some tests on the conversion between the default C++ bindings and
79 * the checked C++ bindings.
80 */
81static void check_conversion(isl_ctx *ctx)
82{
86}
87
88int main()
89{
90 isl_ctx *ctx = isl_ctx_alloc();
91
93
95
96 isl_ctx_free(ctx);
97
98 return EXIT_SUCCESS;
99}
isl_ctx * isl_ctx_alloc(void)
Definition: isl_ctx.c:261
#define isl_die(ctx, errno, msg, code)
Definition: ctx.h:137
@ isl_error_unknown
Definition: ctx.h:78
void isl_ctx_free(isl_ctx *ctx)
Definition: isl_ctx.c:288
const char * set
Definition: isl_test.c:1356
const char * set2
Definition: isl_test.c:4204
static void check_conversion_null(isl_ctx *ctx)
static void check_conversion(isl_ctx *ctx)
static void check_conversion_call(isl_ctx *ctx)
static void check_conversion_equal(isl_ctx *ctx)
static void f_unchecked(isl::set set)
static void f_checked(isl::checked::set set)
isl_stat isl_options_set_on_error(isl_ctx *ctx, int val)
#define ISL_ON_ERROR_ABORT
Definition: options.h:31