Error reporting on erroneous ":> void" in select component
Posted: Wed May 23, 2018 6:12 pm
Have a look at this. Search for "???".
My question is: is the error reporting correct? When that void is removed the compiler thinks the role has changed to ok, because then it compiles and runs.
By just removing the erronoeus ":> void" also these three are removed:
Here is the code:
My question is: is the error reporting correct? When that void is removed the compiler thinks the role has changed to ok, because then it compiles and runs.
By just removing the erronoeus ":> void" also these three are removed:
Code: Select all
// error: trying to call slave function from a client interface
// error: void value not ignored as it ought to be
// error: invalid side effect in select
Code: Select all
#include <platform.h> // core
#include <stdio.h>
#include <timer.h> // delay_milliseconds(200), XS1_TIMER_HZ etc
#define DEBUG_PRINT_TEST 1
#define debug_print(fmt, ...) do { if(DEBUG_PRINT_TEST) printf(fmt, __VA_ARGS__); } while (0)
typedef enum {false,true} bool;
typedef signed int time32_t;
typedef unsigned data_t;
typedef interface notify_if_t {
void start_collect_data (void);
[[notification]]
slave void data_ready (void);
[[clears_notification]]
data_t get_data (void);
} notify_if_t;
[[combinable]]
void server_task (server notify_if_t i_notify) {
timer tmr;
time32_t time;
bool collectData = false;
data_t data = 0;
tmr :> time;
while (1) {
select {
case i_notify.start_collect_data (void) : {
collectData = true;
debug_print ("\n%s\n", "start");
tmr :> time;
} break;
case (collectData == true) => tmr when timerafter (time) :> void : {
collectData = false;
data++; // This is supposed to take a while, that's why we used notification: to get it decoupled
debug_print ("inc %u\n", data);
i_notify.data_ready();
} break;
case i_notify.get_data (void) -> data_t return_Data : {
debug_print ("sent %u\n", data);
return_Data = data;
} break;
}
}
}
[[combinable]]
void client_task (client notify_if_t i_notify) {
timer tmr;
time32_t time;
bool expect_notification = false;
tmr :> time;
while (1) {
select {
case (expect_notification == false) => tmr when timerafter (time) :> void : {
i_notify.start_collect_data();
expect_notification = true;
} break;
case (expect_notification == true) => i_notify.data_ready() :> void : { // ???
// error: trying to call slave function from a client interface
// error: void value not ignored as it ought to be
// error: invalid side effect in select
// case (expect_notification == true) => i_notify.data_ready() : { // WORKS!
data_t data = i_notify.get_data();
debug_print ("got %u\n", data);
expect_notification = false;
time += XS1_TIMER_HZ; // 1 second
} break;
}
}
}
int main() {
notify_if_t if_notify;
par {
server_task(if_notify);
client_task(if_notify);
}
return 0;
}