From 6725b2fdf67f49e6e5009637df9b9f7a7bc57ff9 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 27 May 2016 08:37:05 +0100 Subject: [PATCH] Fix unused variable warnings in test-suite --- Examples/test-suite/insert_directive.i | 2 +- Examples/test-suite/nested_extend_c.i | 4 ++ Examples/test-suite/operator_overload.i | 94 ++++++++++++------------- Examples/test-suite/typemap_manyargs.i | 1 + 4 files changed, 52 insertions(+), 49 deletions(-) diff --git a/Examples/test-suite/insert_directive.i b/Examples/test-suite/insert_directive.i index 8ad966a99..36c3af6c6 100644 --- a/Examples/test-suite/insert_directive.i +++ b/Examples/test-suite/insert_directive.i @@ -34,5 +34,5 @@ int inserted_wrapper(int i) { return inserted_header3(i); } %init %{ // %inserted code %init -int inserted_init_value = inserted_wrapper(0); +int SWIGUNUSED inserted_init_value = inserted_wrapper(0); %} diff --git a/Examples/test-suite/nested_extend_c.i b/Examples/test-suite/nested_extend_c.i index 8fde075a4..032619f8e 100644 --- a/Examples/test-suite/nested_extend_c.i +++ b/Examples/test-suite/nested_extend_c.i @@ -98,5 +98,9 @@ typedef struct { static struct { int i; } THING; + +int useThing() { + return THING.i; +} %} diff --git a/Examples/test-suite/operator_overload.i b/Examples/test-suite/operator_overload.i index d674f09d5..af884e5b4 100644 --- a/Examples/test-suite/operator_overload.i +++ b/Examples/test-suite/operator_overload.i @@ -93,8 +93,6 @@ see bottom for a set of possible tests #include /* for named logical operator, eg 'operator or' */ #endif -#include - class Op { public: int i; @@ -249,8 +247,8 @@ public: %{ - -#include +#include +#define ASSERT(X) { if (!(X)) { throw std::runtime_error(#X); } } void Op::sanity_check() { @@ -262,66 +260,66 @@ void Op::sanity_check() Op dd=d; // assignment operator // test equality - assert(a!=b); - assert(b==c); - assert(a!=d); - assert(d==dd); + ASSERT(a!=b); + ASSERT(b==c); + ASSERT(a!=d); + ASSERT(d==dd); // test < - assert(a=c); - assert(b>d); - assert(b>=d); + ASSERT(a=c); + ASSERT(b>d); + ASSERT(b>=d); // test += Op e=3; e+=d; - assert(e==b); + ASSERT(e==b); e-=c; - assert(e==a); + ASSERT(e==a); e=Op(1); e*=b; - assert(e==c); + ASSERT(e==c); e/=d; - assert(e==d); + ASSERT(e==d); e%=c; - assert(e==d); + ASSERT(e==d); // test + Op f(1),g(1); - assert(f+g==Op(2)); - assert(f-g==Op(0)); - assert(f*g==Op(1)); - assert(f/g==Op(1)); - assert(f%g==Op(0)); + ASSERT(f+g==Op(2)); + ASSERT(f-g==Op(0)); + ASSERT(f*g==Op(1)); + ASSERT(f/g==Op(1)); + ASSERT(f%g==Op(0)); // test unary operators - assert(!a==true); - assert(!b==false); - assert(-a==a); - assert(-b==Op(-5)); + ASSERT(!a==true); + ASSERT(!b==false); + ASSERT(-a==a); + ASSERT(-b==Op(-5)); // test [] Op h=3; - assert(h[0]==3); - assert(h[1]==0); + ASSERT(h[0]==3); + ASSERT(h[1]==0); h[0]=2; // set - assert(h[0]==2); + ASSERT(h[0]==2); h[1]=2; // ignored - assert(h[0]==2); - assert(h[1]==0); + ASSERT(h[0]==2); + ASSERT(h[1]==0); // test () Op i=3; - assert(i()==3); - assert(i(1)==4); - assert(i(1,2)==6); + ASSERT(i()==3); + ASSERT(i(1)==4); + ASSERT(i(1,2)==6); // plus add some code to check the __str__ fn - //assert(str(Op(1))=="Op(1)"); - //assert(str(Op(-3))=="Op(-3)"); + //ASSERT(str(Op(1))=="Op(1)"); + //ASSERT(str(Op(-3))=="Op(-3)"); // test ++ and -- Op j(100); @@ -329,36 +327,36 @@ void Op::sanity_check() { Op newOp = j++; int newInt = original++; - assert(j.i == original); - assert(newOp.i == newInt); + ASSERT(j.i == original); + ASSERT(newOp.i == newInt); } { Op newOp = j--; int newInt = original--; - assert(j.i == original); - assert(newOp.i == newInt); + ASSERT(j.i == original); + ASSERT(newOp.i == newInt); } { Op newOp = ++j; int newInt = ++original; - assert(j.i == original); - assert(newOp.i == newInt); + ASSERT(j.i == original); + ASSERT(newOp.i == newInt); } { Op newOp = --j; int newInt = --original; - assert(j.i == original); - assert(newOp.i == newInt); + ASSERT(j.i == original); + ASSERT(newOp.i == newInt); } // cast operators Op k=3; int check_k = k; - assert (check_k == 3); + ASSERT (check_k == 3); Op l=4; double check_l = l; - assert (check_l == 4); + ASSERT (check_l == 4); } %} diff --git a/Examples/test-suite/typemap_manyargs.i b/Examples/test-suite/typemap_manyargs.i index d26e97714..426fcca1b 100644 --- a/Examples/test-suite/typemap_manyargs.i +++ b/Examples/test-suite/typemap_manyargs.i @@ -13,6 +13,7 @@ $9 = &temp9; $10 = &temp10; // the code generated for this was arg20 = &temp10; and arg20 does not exist. int $10_ptr = 0; // Was arg20_ptr + (void)$10_ptr; } %inline %{