From 4d1de9fe611824d124c44dda7c26e5284a8ac705 Mon Sep 17 00:00:00 2001 From: Smit-create Date: Sun, 28 May 2023 08:52:30 +0530 Subject: [PATCH 1/5] Support header file in ccallable --- src/lpython/semantics/python_ast_to_asr.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lpython/semantics/python_ast_to_asr.cpp b/src/lpython/semantics/python_ast_to_asr.cpp index 9f01d1c9f3..dc214e6db6 100644 --- a/src/lpython/semantics/python_ast_to_asr.cpp +++ b/src/lpython/semantics/python_ast_to_asr.cpp @@ -3809,9 +3809,9 @@ class SymbolTableVisitor : public CommonVisitor { AST::Call_t *call_d = AST::down_cast(dec); if (AST::is_a(*call_d->m_func)) { std::string name = AST::down_cast(call_d->m_func)->m_id; - if (name == "ccall") { + if (name == "ccall" || "ccallable") { current_procedure_abi_type = ASR::abiType::BindC; - current_procedure_interface = true; + if (name == "ccall") current_procedure_interface = true; if (call_d->n_keywords > 0) { for (size_t i=0; i < call_d->n_keywords; i++) { if (std::string(call_d->m_keywords[i].m_arg) == "header") { @@ -3820,7 +3820,7 @@ class SymbolTableVisitor : public CommonVisitor { call_d->m_keywords[i].m_value)->m_value; c_header_file = s2c(al, header_name); } else { - throw SemanticError("header should be constant string in ccall", + throw SemanticError("header should be constant string in ccall/ccallable", x.base.base.loc); } } From edf0bc1b68fe95a17431bc6fc63381a55cf81031 Mon Sep 17 00:00:00 2001 From: Smit-create Date: Sun, 28 May 2023 08:52:44 +0530 Subject: [PATCH 2/5] Emit header files --- src/libasr/codegen/asr_to_c.cpp | 24 ++++++++++++++++++++++++ src/libasr/codegen/asr_to_c_cpp.h | 10 ++++++++++ 2 files changed, 34 insertions(+) diff --git a/src/libasr/codegen/asr_to_c.cpp b/src/libasr/codegen/asr_to_c.cpp index e783535860..664a7c9690 100644 --- a/src/libasr/codegen/asr_to_c.cpp +++ b/src/libasr/codegen/asr_to_c.cpp @@ -1,4 +1,5 @@ #include +#include #include #include @@ -655,6 +656,7 @@ R"( #include #include +#ifndef ASSERT #define ASSERT(cond) \ { \ if (!(cond)) { \ @@ -665,6 +667,9 @@ R"( exit(1); \ } \ } +#endif + +#ifndef ASSERT_MSG #define ASSERT_MSG(cond, msg) \ { \ if (!(cond)) { \ @@ -677,6 +682,7 @@ R"( exit(1); \ } \ } +#endif )"; @@ -807,6 +813,24 @@ R"( } src = to_include + head + array_types_decls + unit_src + ds_funcs_defined + util_funcs_defined; + if (!emit_headers.empty()) { + std::string to_includes_1 = ""; + for (auto &s: headers) { + to_includes_1 += "#include <" + s + ">\n"; + } + for (auto &f_name: emit_headers) { + std::ofstream out_file; + std::string out_src = to_includes_1 + head + f_name.second; + std::string ifdefs = f_name.first.substr(0, f_name.first.length() - 2); + std::transform(ifdefs.begin(), ifdefs.end(), ifdefs.begin(), ::toupper); + ifdefs += "_H"; + out_src = "#ifndef " + ifdefs + "\n#define " + ifdefs + "\n\n" + out_src; + out_src += "\n\n#endif\n"; + out_file.open(f_name.first); + out_file << out_src; + out_file.close(); + } + } } void visit_Module(const ASR::Module_t &x) { diff --git a/src/libasr/codegen/asr_to_c_cpp.h b/src/libasr/codegen/asr_to_c_cpp.h index a5828eab37..91ea23b4b1 100644 --- a/src/libasr/codegen/asr_to_c_cpp.h +++ b/src/libasr/codegen/asr_to_c_cpp.h @@ -104,6 +104,7 @@ class BaseCCPPVisitor : public ASR::BaseVisitor std::map sym_info; std::map const_var_names; std::map gotoid2name; + std::map emit_headers; // Output configuration: // Use std::string or char* @@ -622,6 +623,15 @@ R"(#include } sub += "\n"; src = sub; + if (f_type->m_abi == ASR::abiType::BindC + && f_type->m_deftype == ASR::deftypeType::Implementation) { + if (x.m_c_header) { + std::string header_name = std::string(x.m_c_header); + user_headers.insert(header_name); + emit_headers[header_name]+= "\n" + src; + src = ""; + } + } current_scope = current_scope_copy; } From 714d673b3418de40aac542a48e6fa394784efc3e Mon Sep 17 00:00:00 2001 From: Smit-create Date: Sun, 28 May 2023 08:56:52 +0530 Subject: [PATCH 3/5] Move ASSERT in runtime lib --- src/libasr/codegen/asr_to_c.cpp | 28 ---------------------- src/libasr/runtime/lfortran_intrinsics.h | 30 ++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 28 deletions(-) diff --git a/src/libasr/codegen/asr_to_c.cpp b/src/libasr/codegen/asr_to_c.cpp index 664a7c9690..69ec369bd3 100644 --- a/src/libasr/codegen/asr_to_c.cpp +++ b/src/libasr/codegen/asr_to_c.cpp @@ -656,34 +656,6 @@ R"( #include #include -#ifndef ASSERT -#define ASSERT(cond) \ - { \ - if (!(cond)) { \ - printf("%s%s", "ASSERT failed: ", __FILE__); \ - printf("%s%s", "\nfunction ", __func__); \ - printf("%s%d%s", "(), line number ", __LINE__, " at \n"); \ - printf("%s%s", #cond, "\n"); \ - exit(1); \ - } \ - } -#endif - -#ifndef ASSERT_MSG -#define ASSERT_MSG(cond, msg) \ - { \ - if (!(cond)) { \ - printf("%s%s", "ASSERT failed: ", __FILE__); \ - printf("%s%s", "\nfunction ", __func__); \ - printf("%s%d%s", "(), line number ", __LINE__, " at \n"); \ - printf("%s%s", #cond, "\n"); \ - printf("%s", "ERROR MESSAGE:\n"); \ - printf("%s%s", msg, "\n"); \ - exit(1); \ - } \ - } -#endif - )"; std::string indent(indentation_level * indentation_spaces, ' '); diff --git a/src/libasr/runtime/lfortran_intrinsics.h b/src/libasr/runtime/lfortran_intrinsics.h index 827bd8c9df..a94cbcabca 100644 --- a/src/libasr/runtime/lfortran_intrinsics.h +++ b/src/libasr/runtime/lfortran_intrinsics.h @@ -34,6 +34,36 @@ typedef double _Complex double_complex_t; #define LFORTRAN_API /* Nothing */ #endif + + +#ifndef ASSERT +#define ASSERT(cond) \ + { \ + if (!(cond)) { \ + printf("%s%s", "ASSERT failed: ", __FILE__); \ + printf("%s%s", "\nfunction ", __func__); \ + printf("%s%d%s", "(), line number ", __LINE__, " at \n"); \ + printf("%s%s", #cond, "\n"); \ + exit(1); \ + } \ + } +#endif + +#ifndef ASSERT_MSG +#define ASSERT_MSG(cond, msg) \ + { \ + if (!(cond)) { \ + printf("%s%s", "ASSERT failed: ", __FILE__); \ + printf("%s%s", "\nfunction ", __func__); \ + printf("%s%d%s", "(), line number ", __LINE__, " at \n"); \ + printf("%s%s", #cond, "\n"); \ + printf("%s", "ERROR MESSAGE:\n"); \ + printf("%s%s", msg, "\n"); \ + exit(1); \ + } \ + } +#endif + LFORTRAN_API double _lfortran_sum(int n, double *v); LFORTRAN_API void _lfortran_random_number(int n, double *v); LFORTRAN_API double _lfortran_random(); From db70507dd2b1ec7cf227a7192cfed72aeb38c127 Mon Sep 17 00:00:00 2001 From: Smit-create Date: Sun, 28 May 2023 08:57:02 +0530 Subject: [PATCH 4/5] Add a test --- integration_tests/bindc_03.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/integration_tests/bindc_03.py b/integration_tests/bindc_03.py index d1153d36f2..d047b62bbb 100644 --- a/integration_tests/bindc_03.py +++ b/integration_tests/bindc_03.py @@ -42,6 +42,14 @@ def h(q_void: CPtr) -> None: print(el) assert el == i * i + i%2 + +@ccallable(header="_test_bindc_03_my_header.h") +def test_emit_header_ccallable() -> i32: + i: i32 = 5 + assert i == 5 + i = i*5 + return i + 10 + def run(): a: CPtr array_wrapped: ArrayWrapped = ArrayWrapped(a) @@ -59,5 +67,6 @@ def run(): f(array_wrapped.array) array_wrapped1 = array_wrapped h(array_wrapped1.array) + assert test_emit_header_ccallable() == 35 run() From cd204087514ab37934dbf7eb7330350521eff54d Mon Sep 17 00:00:00 2001 From: Smit-create Date: Sun, 28 May 2023 08:57:14 +0530 Subject: [PATCH 5/5] Update references --- tests/reference/c-bindc_06-a30d20f.json | 2 +- tests/reference/c-bindc_06-a30d20f.stdout | 23 ------------------- tests/reference/c-c_interop1-e215531.json | 2 +- tests/reference/c-c_interop1-e215531.stdout | 23 ------------------- tests/reference/c-expr7-bb2692a.json | 2 +- tests/reference/c-expr7-bb2692a.stdout | 23 ------------------- tests/reference/c-expr_01-28f449f.json | 2 +- tests/reference/c-expr_01-28f449f.stdout | 23 ------------------- tests/reference/c-expr_11-c452314.json | 2 +- tests/reference/c-expr_11-c452314.stdout | 23 ------------------- tests/reference/c-expr_12-93c7780.json | 2 +- tests/reference/c-expr_12-93c7780.stdout | 23 ------------------- tests/reference/c-func_static_01-fc146ec.json | 2 +- .../reference/c-func_static_01-fc146ec.stdout | 23 ------------------- .../reference/c-import_order_01-3ebf3c3.json | 2 +- .../c-import_order_01-3ebf3c3.stdout | 23 ------------------- tests/reference/c-loop1-3e341c7.json | 2 +- tests/reference/c-loop1-3e341c7.stdout | 23 ------------------- tests/reference/c-loop2-ce7de51.json | 2 +- tests/reference/c-loop2-ce7de51.stdout | 23 ------------------- tests/reference/c-loop4-eec10d3.json | 2 +- tests/reference/c-loop4-eec10d3.stdout | 23 ------------------- tests/reference/c-print_01-4d44628.json | 2 +- tests/reference/c-print_01-4d44628.stdout | 23 ------------------- tests/reference/c-test_import_02-d2c54c4.json | 2 +- .../reference/c-test_import_02-d2c54c4.stdout | 23 ------------------- tests/reference/c-test_issue_518-fbbd299.json | 2 +- .../reference/c-test_issue_518-fbbd299.stdout | 23 ------------------- .../reference/c-variable_decl_03-fa1823b.json | 2 +- .../c-variable_decl_03-fa1823b.stdout | 23 ------------------- 30 files changed, 15 insertions(+), 360 deletions(-) diff --git a/tests/reference/c-bindc_06-a30d20f.json b/tests/reference/c-bindc_06-a30d20f.json index 592dc700df..427b551734 100644 --- a/tests/reference/c-bindc_06-a30d20f.json +++ b/tests/reference/c-bindc_06-a30d20f.json @@ -6,7 +6,7 @@ "outfile": null, "outfile_hash": null, "stdout": "c-bindc_06-a30d20f.stdout", - "stdout_hash": "e8983d6fcd2d2c6e975daae9aed736c86c8432adaed965caeef12cba", + "stdout_hash": "1592d4a00bd387b8ee0a53ab5671575310052fc871b4dfca170386fd", "stderr": null, "stderr_hash": null, "returncode": 0 diff --git a/tests/reference/c-bindc_06-a30d20f.stdout b/tests/reference/c-bindc_06-a30d20f.stdout index aadf36894b..7c7d2428d7 100644 --- a/tests/reference/c-bindc_06-a30d20f.stdout +++ b/tests/reference/c-bindc_06-a30d20f.stdout @@ -8,29 +8,6 @@ #include #include -#define ASSERT(cond) \ - { \ - if (!(cond)) { \ - printf("%s%s", "ASSERT failed: ", __FILE__); \ - printf("%s%s", "\nfunction ", __func__); \ - printf("%s%d%s", "(), line number ", __LINE__, " at \n"); \ - printf("%s%s", #cond, "\n"); \ - exit(1); \ - } \ - } -#define ASSERT_MSG(cond, msg) \ - { \ - if (!(cond)) { \ - printf("%s%s", "ASSERT failed: ", __FILE__); \ - printf("%s%s", "\nfunction ", __func__); \ - printf("%s%d%s", "(), line number ", __LINE__, " at \n"); \ - printf("%s%s", #cond, "\n"); \ - printf("%s", "ERROR MESSAGE:\n"); \ - printf("%s%s", msg, "\n"); \ - exit(1); \ - } \ - } - struct dimension_descriptor { diff --git a/tests/reference/c-c_interop1-e215531.json b/tests/reference/c-c_interop1-e215531.json index 0809bf54ac..5033cb3c95 100644 --- a/tests/reference/c-c_interop1-e215531.json +++ b/tests/reference/c-c_interop1-e215531.json @@ -6,7 +6,7 @@ "outfile": null, "outfile_hash": null, "stdout": "c-c_interop1-e215531.stdout", - "stdout_hash": "79bf04c21b0db44755fa1828851ba74ce803ba1748da76e0144e2908", + "stdout_hash": "6ff32cb0aeb8edf4f78af311a25512fc6f8f708e682ce94137f160ee", "stderr": null, "stderr_hash": null, "returncode": 0 diff --git a/tests/reference/c-c_interop1-e215531.stdout b/tests/reference/c-c_interop1-e215531.stdout index 32016f6492..05f548d102 100644 --- a/tests/reference/c-c_interop1-e215531.stdout +++ b/tests/reference/c-c_interop1-e215531.stdout @@ -6,29 +6,6 @@ #include #include -#define ASSERT(cond) \ - { \ - if (!(cond)) { \ - printf("%s%s", "ASSERT failed: ", __FILE__); \ - printf("%s%s", "\nfunction ", __func__); \ - printf("%s%d%s", "(), line number ", __LINE__, " at \n"); \ - printf("%s%s", #cond, "\n"); \ - exit(1); \ - } \ - } -#define ASSERT_MSG(cond, msg) \ - { \ - if (!(cond)) { \ - printf("%s%s", "ASSERT failed: ", __FILE__); \ - printf("%s%s", "\nfunction ", __func__); \ - printf("%s%d%s", "(), line number ", __LINE__, " at \n"); \ - printf("%s%s", #cond, "\n"); \ - printf("%s", "ERROR MESSAGE:\n"); \ - printf("%s%s", msg, "\n"); \ - exit(1); \ - } \ - } - struct dimension_descriptor { diff --git a/tests/reference/c-expr7-bb2692a.json b/tests/reference/c-expr7-bb2692a.json index 011c8dedcb..66f65cdd93 100644 --- a/tests/reference/c-expr7-bb2692a.json +++ b/tests/reference/c-expr7-bb2692a.json @@ -6,7 +6,7 @@ "outfile": null, "outfile_hash": null, "stdout": "c-expr7-bb2692a.stdout", - "stdout_hash": "c5afb46e3538eeeff7e1b50eac49c6f2fa57468bb40d278b207ee60d", + "stdout_hash": "6ec5c40f07c1fb2fbfad9c3ff031e50cf077c0ad2412c7be962d9e93", "stderr": "c-expr7-bb2692a.stderr", "stderr_hash": "6e9790ac88db1a9ead8f64a91ba8a6605de67167037908a74b77be0c", "returncode": 0 diff --git a/tests/reference/c-expr7-bb2692a.stdout b/tests/reference/c-expr7-bb2692a.stdout index 557b71fb43..4a54ba8b23 100644 --- a/tests/reference/c-expr7-bb2692a.stdout +++ b/tests/reference/c-expr7-bb2692a.stdout @@ -8,29 +8,6 @@ #include #include -#define ASSERT(cond) \ - { \ - if (!(cond)) { \ - printf("%s%s", "ASSERT failed: ", __FILE__); \ - printf("%s%s", "\nfunction ", __func__); \ - printf("%s%d%s", "(), line number ", __LINE__, " at \n"); \ - printf("%s%s", #cond, "\n"); \ - exit(1); \ - } \ - } -#define ASSERT_MSG(cond, msg) \ - { \ - if (!(cond)) { \ - printf("%s%s", "ASSERT failed: ", __FILE__); \ - printf("%s%s", "\nfunction ", __func__); \ - printf("%s%d%s", "(), line number ", __LINE__, " at \n"); \ - printf("%s%s", #cond, "\n"); \ - printf("%s", "ERROR MESSAGE:\n"); \ - printf("%s%s", msg, "\n"); \ - exit(1); \ - } \ - } - struct dimension_descriptor { diff --git a/tests/reference/c-expr_01-28f449f.json b/tests/reference/c-expr_01-28f449f.json index e6dfba66ed..1ad0428f47 100644 --- a/tests/reference/c-expr_01-28f449f.json +++ b/tests/reference/c-expr_01-28f449f.json @@ -6,7 +6,7 @@ "outfile": null, "outfile_hash": null, "stdout": "c-expr_01-28f449f.stdout", - "stdout_hash": "f7ff3e7ee6518de7ff6bc41aa1ab242c7dbf9fca4482e5de47209c42", + "stdout_hash": "54d2c8dc7b28702c7907cd829a3777bdc4f2cf13dc597113a0074839", "stderr": null, "stderr_hash": null, "returncode": 0 diff --git a/tests/reference/c-expr_01-28f449f.stdout b/tests/reference/c-expr_01-28f449f.stdout index d4785bcea1..99f94aa726 100644 --- a/tests/reference/c-expr_01-28f449f.stdout +++ b/tests/reference/c-expr_01-28f449f.stdout @@ -6,29 +6,6 @@ #include #include -#define ASSERT(cond) \ - { \ - if (!(cond)) { \ - printf("%s%s", "ASSERT failed: ", __FILE__); \ - printf("%s%s", "\nfunction ", __func__); \ - printf("%s%d%s", "(), line number ", __LINE__, " at \n"); \ - printf("%s%s", #cond, "\n"); \ - exit(1); \ - } \ - } -#define ASSERT_MSG(cond, msg) \ - { \ - if (!(cond)) { \ - printf("%s%s", "ASSERT failed: ", __FILE__); \ - printf("%s%s", "\nfunction ", __func__); \ - printf("%s%d%s", "(), line number ", __LINE__, " at \n"); \ - printf("%s%s", #cond, "\n"); \ - printf("%s", "ERROR MESSAGE:\n"); \ - printf("%s%s", msg, "\n"); \ - exit(1); \ - } \ - } - struct dimension_descriptor { diff --git a/tests/reference/c-expr_11-c452314.json b/tests/reference/c-expr_11-c452314.json index 3e4edd3149..34e95dfd8d 100644 --- a/tests/reference/c-expr_11-c452314.json +++ b/tests/reference/c-expr_11-c452314.json @@ -6,7 +6,7 @@ "outfile": null, "outfile_hash": null, "stdout": "c-expr_11-c452314.stdout", - "stdout_hash": "3ff86fbef1a6ada1ca91694b6cf50b08d58abb9f3d32672698655b45", + "stdout_hash": "990486bcfab642985e506a1ee8ff20218e233b0d19035e8acf2d407c", "stderr": null, "stderr_hash": null, "returncode": 0 diff --git a/tests/reference/c-expr_11-c452314.stdout b/tests/reference/c-expr_11-c452314.stdout index 21950afbc7..bdc2ab60b0 100644 --- a/tests/reference/c-expr_11-c452314.stdout +++ b/tests/reference/c-expr_11-c452314.stdout @@ -6,29 +6,6 @@ #include #include -#define ASSERT(cond) \ - { \ - if (!(cond)) { \ - printf("%s%s", "ASSERT failed: ", __FILE__); \ - printf("%s%s", "\nfunction ", __func__); \ - printf("%s%d%s", "(), line number ", __LINE__, " at \n"); \ - printf("%s%s", #cond, "\n"); \ - exit(1); \ - } \ - } -#define ASSERT_MSG(cond, msg) \ - { \ - if (!(cond)) { \ - printf("%s%s", "ASSERT failed: ", __FILE__); \ - printf("%s%s", "\nfunction ", __func__); \ - printf("%s%d%s", "(), line number ", __LINE__, " at \n"); \ - printf("%s%s", #cond, "\n"); \ - printf("%s", "ERROR MESSAGE:\n"); \ - printf("%s%s", msg, "\n"); \ - exit(1); \ - } \ - } - struct dimension_descriptor { diff --git a/tests/reference/c-expr_12-93c7780.json b/tests/reference/c-expr_12-93c7780.json index d4f6dd2fe3..d5c964d11e 100644 --- a/tests/reference/c-expr_12-93c7780.json +++ b/tests/reference/c-expr_12-93c7780.json @@ -6,7 +6,7 @@ "outfile": null, "outfile_hash": null, "stdout": "c-expr_12-93c7780.stdout", - "stdout_hash": "4a67164684f646b94101df4dba378f02ee7585d7087093459a791c39", + "stdout_hash": "eb0832038676f31ac362e2c3b4709d5f1b9a9be2ca9c5b13d1a29613", "stderr": null, "stderr_hash": null, "returncode": 0 diff --git a/tests/reference/c-expr_12-93c7780.stdout b/tests/reference/c-expr_12-93c7780.stdout index f0f6070824..0e16084ebe 100644 --- a/tests/reference/c-expr_12-93c7780.stdout +++ b/tests/reference/c-expr_12-93c7780.stdout @@ -6,29 +6,6 @@ #include #include -#define ASSERT(cond) \ - { \ - if (!(cond)) { \ - printf("%s%s", "ASSERT failed: ", __FILE__); \ - printf("%s%s", "\nfunction ", __func__); \ - printf("%s%d%s", "(), line number ", __LINE__, " at \n"); \ - printf("%s%s", #cond, "\n"); \ - exit(1); \ - } \ - } -#define ASSERT_MSG(cond, msg) \ - { \ - if (!(cond)) { \ - printf("%s%s", "ASSERT failed: ", __FILE__); \ - printf("%s%s", "\nfunction ", __func__); \ - printf("%s%d%s", "(), line number ", __LINE__, " at \n"); \ - printf("%s%s", #cond, "\n"); \ - printf("%s", "ERROR MESSAGE:\n"); \ - printf("%s%s", msg, "\n"); \ - exit(1); \ - } \ - } - struct dimension_descriptor { diff --git a/tests/reference/c-func_static_01-fc146ec.json b/tests/reference/c-func_static_01-fc146ec.json index af6943b458..050fe2989c 100644 --- a/tests/reference/c-func_static_01-fc146ec.json +++ b/tests/reference/c-func_static_01-fc146ec.json @@ -6,7 +6,7 @@ "outfile": null, "outfile_hash": null, "stdout": "c-func_static_01-fc146ec.stdout", - "stdout_hash": "c3796deea978e5a6066da91a0e89867135b68a3c89059fcf8996b087", + "stdout_hash": "73b3d25f714c83fd772abb3012b472ef35be68e4a423d8b598fd0e7c", "stderr": null, "stderr_hash": null, "returncode": 0 diff --git a/tests/reference/c-func_static_01-fc146ec.stdout b/tests/reference/c-func_static_01-fc146ec.stdout index e55a3d49f8..e57ad107b0 100644 --- a/tests/reference/c-func_static_01-fc146ec.stdout +++ b/tests/reference/c-func_static_01-fc146ec.stdout @@ -6,29 +6,6 @@ #include #include -#define ASSERT(cond) \ - { \ - if (!(cond)) { \ - printf("%s%s", "ASSERT failed: ", __FILE__); \ - printf("%s%s", "\nfunction ", __func__); \ - printf("%s%d%s", "(), line number ", __LINE__, " at \n"); \ - printf("%s%s", #cond, "\n"); \ - exit(1); \ - } \ - } -#define ASSERT_MSG(cond, msg) \ - { \ - if (!(cond)) { \ - printf("%s%s", "ASSERT failed: ", __FILE__); \ - printf("%s%s", "\nfunction ", __func__); \ - printf("%s%d%s", "(), line number ", __LINE__, " at \n"); \ - printf("%s%s", #cond, "\n"); \ - printf("%s", "ERROR MESSAGE:\n"); \ - printf("%s%s", msg, "\n"); \ - exit(1); \ - } \ - } - struct dimension_descriptor { diff --git a/tests/reference/c-import_order_01-3ebf3c3.json b/tests/reference/c-import_order_01-3ebf3c3.json index 5477786c56..21c1a65f49 100644 --- a/tests/reference/c-import_order_01-3ebf3c3.json +++ b/tests/reference/c-import_order_01-3ebf3c3.json @@ -6,7 +6,7 @@ "outfile": null, "outfile_hash": null, "stdout": "c-import_order_01-3ebf3c3.stdout", - "stdout_hash": "d844d0d693ba8a9867f29b17de6f66c99f2096b7a14efeb4c5d698d2", + "stdout_hash": "b65b2f95b190f9db269e1c9079c79c906bd2847a8b481089230cc2bd", "stderr": null, "stderr_hash": null, "returncode": 0 diff --git a/tests/reference/c-import_order_01-3ebf3c3.stdout b/tests/reference/c-import_order_01-3ebf3c3.stdout index 0e7c567af1..ebff917b73 100644 --- a/tests/reference/c-import_order_01-3ebf3c3.stdout +++ b/tests/reference/c-import_order_01-3ebf3c3.stdout @@ -6,29 +6,6 @@ #include #include -#define ASSERT(cond) \ - { \ - if (!(cond)) { \ - printf("%s%s", "ASSERT failed: ", __FILE__); \ - printf("%s%s", "\nfunction ", __func__); \ - printf("%s%d%s", "(), line number ", __LINE__, " at \n"); \ - printf("%s%s", #cond, "\n"); \ - exit(1); \ - } \ - } -#define ASSERT_MSG(cond, msg) \ - { \ - if (!(cond)) { \ - printf("%s%s", "ASSERT failed: ", __FILE__); \ - printf("%s%s", "\nfunction ", __func__); \ - printf("%s%d%s", "(), line number ", __LINE__, " at \n"); \ - printf("%s%s", #cond, "\n"); \ - printf("%s", "ERROR MESSAGE:\n"); \ - printf("%s%s", msg, "\n"); \ - exit(1); \ - } \ - } - struct dimension_descriptor { diff --git a/tests/reference/c-loop1-3e341c7.json b/tests/reference/c-loop1-3e341c7.json index 8b0073364f..ae53b0237d 100644 --- a/tests/reference/c-loop1-3e341c7.json +++ b/tests/reference/c-loop1-3e341c7.json @@ -6,7 +6,7 @@ "outfile": null, "outfile_hash": null, "stdout": "c-loop1-3e341c7.stdout", - "stdout_hash": "a41b600614c4f3501baff087d84588b97238af4f25b851874b133522", + "stdout_hash": "3e0f31f16e81f3ced15b7f243afa362d827e2d3fd65ba945036eb65f", "stderr": null, "stderr_hash": null, "returncode": 0 diff --git a/tests/reference/c-loop1-3e341c7.stdout b/tests/reference/c-loop1-3e341c7.stdout index ab77a32bee..c22ab80382 100644 --- a/tests/reference/c-loop1-3e341c7.stdout +++ b/tests/reference/c-loop1-3e341c7.stdout @@ -6,29 +6,6 @@ #include #include -#define ASSERT(cond) \ - { \ - if (!(cond)) { \ - printf("%s%s", "ASSERT failed: ", __FILE__); \ - printf("%s%s", "\nfunction ", __func__); \ - printf("%s%d%s", "(), line number ", __LINE__, " at \n"); \ - printf("%s%s", #cond, "\n"); \ - exit(1); \ - } \ - } -#define ASSERT_MSG(cond, msg) \ - { \ - if (!(cond)) { \ - printf("%s%s", "ASSERT failed: ", __FILE__); \ - printf("%s%s", "\nfunction ", __func__); \ - printf("%s%d%s", "(), line number ", __LINE__, " at \n"); \ - printf("%s%s", #cond, "\n"); \ - printf("%s", "ERROR MESSAGE:\n"); \ - printf("%s%s", msg, "\n"); \ - exit(1); \ - } \ - } - struct dimension_descriptor { diff --git a/tests/reference/c-loop2-ce7de51.json b/tests/reference/c-loop2-ce7de51.json index 9c4e5e6b85..769b4b59ae 100644 --- a/tests/reference/c-loop2-ce7de51.json +++ b/tests/reference/c-loop2-ce7de51.json @@ -6,7 +6,7 @@ "outfile": null, "outfile_hash": null, "stdout": "c-loop2-ce7de51.stdout", - "stdout_hash": "93bb1a7a58d577117ba34dd94ee7f8f4edac8a188e5f7fa34b3b3ecf", + "stdout_hash": "721c0279f391240cd904b048287ef14cc32d98c56cc16bcec21812b7", "stderr": null, "stderr_hash": null, "returncode": 0 diff --git a/tests/reference/c-loop2-ce7de51.stdout b/tests/reference/c-loop2-ce7de51.stdout index 10a3d0d753..ce4406f1ac 100644 --- a/tests/reference/c-loop2-ce7de51.stdout +++ b/tests/reference/c-loop2-ce7de51.stdout @@ -6,29 +6,6 @@ #include #include -#define ASSERT(cond) \ - { \ - if (!(cond)) { \ - printf("%s%s", "ASSERT failed: ", __FILE__); \ - printf("%s%s", "\nfunction ", __func__); \ - printf("%s%d%s", "(), line number ", __LINE__, " at \n"); \ - printf("%s%s", #cond, "\n"); \ - exit(1); \ - } \ - } -#define ASSERT_MSG(cond, msg) \ - { \ - if (!(cond)) { \ - printf("%s%s", "ASSERT failed: ", __FILE__); \ - printf("%s%s", "\nfunction ", __func__); \ - printf("%s%d%s", "(), line number ", __LINE__, " at \n"); \ - printf("%s%s", #cond, "\n"); \ - printf("%s", "ERROR MESSAGE:\n"); \ - printf("%s%s", msg, "\n"); \ - exit(1); \ - } \ - } - struct dimension_descriptor { diff --git a/tests/reference/c-loop4-eec10d3.json b/tests/reference/c-loop4-eec10d3.json index 0c94586f00..dc28450b1b 100644 --- a/tests/reference/c-loop4-eec10d3.json +++ b/tests/reference/c-loop4-eec10d3.json @@ -6,7 +6,7 @@ "outfile": null, "outfile_hash": null, "stdout": "c-loop4-eec10d3.stdout", - "stdout_hash": "fcac40cfa4688bd9f947e6b94eec42690e91a2ba41dbf2f80db2b3ef", + "stdout_hash": "9241353ca0251a65257d9aa73a48d9ff8f9ab31698ae01372c148e5f", "stderr": null, "stderr_hash": null, "returncode": 0 diff --git a/tests/reference/c-loop4-eec10d3.stdout b/tests/reference/c-loop4-eec10d3.stdout index 1746e8aa3d..b6745fb55c 100644 --- a/tests/reference/c-loop4-eec10d3.stdout +++ b/tests/reference/c-loop4-eec10d3.stdout @@ -6,29 +6,6 @@ #include #include -#define ASSERT(cond) \ - { \ - if (!(cond)) { \ - printf("%s%s", "ASSERT failed: ", __FILE__); \ - printf("%s%s", "\nfunction ", __func__); \ - printf("%s%d%s", "(), line number ", __LINE__, " at \n"); \ - printf("%s%s", #cond, "\n"); \ - exit(1); \ - } \ - } -#define ASSERT_MSG(cond, msg) \ - { \ - if (!(cond)) { \ - printf("%s%s", "ASSERT failed: ", __FILE__); \ - printf("%s%s", "\nfunction ", __func__); \ - printf("%s%d%s", "(), line number ", __LINE__, " at \n"); \ - printf("%s%s", #cond, "\n"); \ - printf("%s", "ERROR MESSAGE:\n"); \ - printf("%s%s", msg, "\n"); \ - exit(1); \ - } \ - } - struct dimension_descriptor { diff --git a/tests/reference/c-print_01-4d44628.json b/tests/reference/c-print_01-4d44628.json index 21a2cbc456..aa4e4c364d 100644 --- a/tests/reference/c-print_01-4d44628.json +++ b/tests/reference/c-print_01-4d44628.json @@ -6,7 +6,7 @@ "outfile": null, "outfile_hash": null, "stdout": "c-print_01-4d44628.stdout", - "stdout_hash": "65aee28fc6091402602cc71f84decd11f58989e0d45ee66272c06170", + "stdout_hash": "1e1b8a95e4d08ffd305a021c5c466121491741c96d84abcbd0a6e26a", "stderr": null, "stderr_hash": null, "returncode": 0 diff --git a/tests/reference/c-print_01-4d44628.stdout b/tests/reference/c-print_01-4d44628.stdout index 93e87edfef..a209616042 100644 --- a/tests/reference/c-print_01-4d44628.stdout +++ b/tests/reference/c-print_01-4d44628.stdout @@ -5,29 +5,6 @@ #include #include -#define ASSERT(cond) \ - { \ - if (!(cond)) { \ - printf("%s%s", "ASSERT failed: ", __FILE__); \ - printf("%s%s", "\nfunction ", __func__); \ - printf("%s%d%s", "(), line number ", __LINE__, " at \n"); \ - printf("%s%s", #cond, "\n"); \ - exit(1); \ - } \ - } -#define ASSERT_MSG(cond, msg) \ - { \ - if (!(cond)) { \ - printf("%s%s", "ASSERT failed: ", __FILE__); \ - printf("%s%s", "\nfunction ", __func__); \ - printf("%s%d%s", "(), line number ", __LINE__, " at \n"); \ - printf("%s%s", #cond, "\n"); \ - printf("%s", "ERROR MESSAGE:\n"); \ - printf("%s%s", msg, "\n"); \ - exit(1); \ - } \ - } - struct dimension_descriptor { diff --git a/tests/reference/c-test_import_02-d2c54c4.json b/tests/reference/c-test_import_02-d2c54c4.json index c330a1d68f..15f54806c0 100644 --- a/tests/reference/c-test_import_02-d2c54c4.json +++ b/tests/reference/c-test_import_02-d2c54c4.json @@ -6,7 +6,7 @@ "outfile": null, "outfile_hash": null, "stdout": "c-test_import_02-d2c54c4.stdout", - "stdout_hash": "6371b638702d5b3520a0cadfb78f9c37a2f6f46a6587c7b71a5c5138", + "stdout_hash": "2697ed4e9d1c123a8c2fe3802d8f8458108393593df377117da85593", "stderr": null, "stderr_hash": null, "returncode": 0 diff --git a/tests/reference/c-test_import_02-d2c54c4.stdout b/tests/reference/c-test_import_02-d2c54c4.stdout index 09acbe4a0a..a51344e50c 100644 --- a/tests/reference/c-test_import_02-d2c54c4.stdout +++ b/tests/reference/c-test_import_02-d2c54c4.stdout @@ -6,29 +6,6 @@ #include #include -#define ASSERT(cond) \ - { \ - if (!(cond)) { \ - printf("%s%s", "ASSERT failed: ", __FILE__); \ - printf("%s%s", "\nfunction ", __func__); \ - printf("%s%d%s", "(), line number ", __LINE__, " at \n"); \ - printf("%s%s", #cond, "\n"); \ - exit(1); \ - } \ - } -#define ASSERT_MSG(cond, msg) \ - { \ - if (!(cond)) { \ - printf("%s%s", "ASSERT failed: ", __FILE__); \ - printf("%s%s", "\nfunction ", __func__); \ - printf("%s%d%s", "(), line number ", __LINE__, " at \n"); \ - printf("%s%s", #cond, "\n"); \ - printf("%s", "ERROR MESSAGE:\n"); \ - printf("%s%s", msg, "\n"); \ - exit(1); \ - } \ - } - struct dimension_descriptor { diff --git a/tests/reference/c-test_issue_518-fbbd299.json b/tests/reference/c-test_issue_518-fbbd299.json index 941dbc6038..a2d41dacce 100644 --- a/tests/reference/c-test_issue_518-fbbd299.json +++ b/tests/reference/c-test_issue_518-fbbd299.json @@ -6,7 +6,7 @@ "outfile": null, "outfile_hash": null, "stdout": "c-test_issue_518-fbbd299.stdout", - "stdout_hash": "bc00265fcbf7ff5970b309323f569394f736b488dbaf12cb2cc7b48f", + "stdout_hash": "b3cdbed3bc61446eb4c3f4829db83c57edb99cdb38e8d9078ecc66fe", "stderr": null, "stderr_hash": null, "returncode": 0 diff --git a/tests/reference/c-test_issue_518-fbbd299.stdout b/tests/reference/c-test_issue_518-fbbd299.stdout index e9a16dd976..b019b5f70c 100644 --- a/tests/reference/c-test_issue_518-fbbd299.stdout +++ b/tests/reference/c-test_issue_518-fbbd299.stdout @@ -6,29 +6,6 @@ #include #include -#define ASSERT(cond) \ - { \ - if (!(cond)) { \ - printf("%s%s", "ASSERT failed: ", __FILE__); \ - printf("%s%s", "\nfunction ", __func__); \ - printf("%s%d%s", "(), line number ", __LINE__, " at \n"); \ - printf("%s%s", #cond, "\n"); \ - exit(1); \ - } \ - } -#define ASSERT_MSG(cond, msg) \ - { \ - if (!(cond)) { \ - printf("%s%s", "ASSERT failed: ", __FILE__); \ - printf("%s%s", "\nfunction ", __func__); \ - printf("%s%d%s", "(), line number ", __LINE__, " at \n"); \ - printf("%s%s", #cond, "\n"); \ - printf("%s", "ERROR MESSAGE:\n"); \ - printf("%s%s", msg, "\n"); \ - exit(1); \ - } \ - } - struct dimension_descriptor { diff --git a/tests/reference/c-variable_decl_03-fa1823b.json b/tests/reference/c-variable_decl_03-fa1823b.json index ba255b91c7..b65f81a4ed 100644 --- a/tests/reference/c-variable_decl_03-fa1823b.json +++ b/tests/reference/c-variable_decl_03-fa1823b.json @@ -6,7 +6,7 @@ "outfile": null, "outfile_hash": null, "stdout": "c-variable_decl_03-fa1823b.stdout", - "stdout_hash": "331731fb69953c59e71abb52b4349c8af67cbbbea5e81986c8c05bc7", + "stdout_hash": "c25ff5a505eb211c7584455ac51300402ff547768d0e5c832d303c9e", "stderr": null, "stderr_hash": null, "returncode": 0 diff --git a/tests/reference/c-variable_decl_03-fa1823b.stdout b/tests/reference/c-variable_decl_03-fa1823b.stdout index 3e3b8dd734..4ce02d871a 100644 --- a/tests/reference/c-variable_decl_03-fa1823b.stdout +++ b/tests/reference/c-variable_decl_03-fa1823b.stdout @@ -5,29 +5,6 @@ #include #include -#define ASSERT(cond) \ - { \ - if (!(cond)) { \ - printf("%s%s", "ASSERT failed: ", __FILE__); \ - printf("%s%s", "\nfunction ", __func__); \ - printf("%s%d%s", "(), line number ", __LINE__, " at \n"); \ - printf("%s%s", #cond, "\n"); \ - exit(1); \ - } \ - } -#define ASSERT_MSG(cond, msg) \ - { \ - if (!(cond)) { \ - printf("%s%s", "ASSERT failed: ", __FILE__); \ - printf("%s%s", "\nfunction ", __func__); \ - printf("%s%d%s", "(), line number ", __LINE__, " at \n"); \ - printf("%s%s", #cond, "\n"); \ - printf("%s", "ERROR MESSAGE:\n"); \ - printf("%s%s", msg, "\n"); \ - exit(1); \ - } \ - } - struct dimension_descriptor {