Mantis 1988

Nonvoid functions can be used as a statement without casting, but cause mandatory warning

P1800-2008/D3a, Sections 13.4.1-2

In Sections 13.4.1-13.4.2

CHANGE

 

Functions can be declared as type void, which do not have a return value. Function calls are expressions

unless of type void, which are statements:

 

a = b + myfunc1(c, d); // call myfunc1 (defined above) as an expression

myprint(a);            // call myprint (defined below) as a statement

 

function void myprint (int a);

...

endfunction

 

It shall be illegal to declare another object with the same name as the function in the scope where the function

is declared or explicitly imported. Inside a function, there is an implied variable with the name of the

function, which may be used in expressions within the function. It is, therefore, also illegal to declare

another object with the same name as the function inside the function scope.

 

13.4.2 Discarding function return values

 

Functions that return a value must be assigned or used in an expression. Calling a nonvoid function as if it

has no return value can result in a warning message. The void data type can be used to discard a function’s

return value by casting the function call to the void type:

void’(some_function());

 

TO

 

Functions can be declared as type void, which do not have a return value. Function calls are may be used as expressions unless of type void, which are statements:

 

a = b + myfunc1(c, d); // call myfunc1 (defined above) as an expression

myprint(a);            // call myprint (defined below) as a statement

 

function void myprint (int a);

...

endfunction

 

Functions that return a value may be used in an assignment or an expression. Calling a nonvoid function as if it has no return value shall be legal, but shall cause a warning. The function can be used as a statement and the return value discarded without a warning by casting the function call to the void type:

void’(some_function());

 

It shall be illegal to declare another object with the same name as the function in the scope where the function

is declared or explicitly imported. Inside a function, there is an implied variable with the name of the

function, which may be used in expressions within the function. It is, therefore, also illegal to declare

another object with the same name as the function inside the function scope.

 

13.4.2 Discarding function return values

 

Functions that return a value must be assigned or used in an expression. Calling a nonvoid function as if it

has no return value can result in a warning message. The void data type can be used to discard a function’s

return value by casting the function call to the void type:

void’(some_function());

 

In Section 13.5,

CHANGE

Tasks and void functions are called as statements within procedural blocks (see 9.2). A nonvoid function call is an operand within an expression.

TO

Tasks and void functions are called as statements within procedural blocks (see 9.2). A nonvoid function call is may be an operand within an expression.