gcc statement expressions do array decay
git-svn-id: svn+ssh://svn.cprover.org/srv/svn/cbmc/trunk@4556 6afb6bc1-c8e4-404c-8f48-9ae832c5b171
This commit is contained in:
parent
c7d2e8523b
commit
e25eaa2f92
|
@ -1,4 +1,4 @@
|
||||||
KNOWNBUG
|
CORE
|
||||||
main.c
|
main.c
|
||||||
|
|
||||||
^EXIT=0$
|
^EXIT=0$
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
char array[40];
|
||||||
|
|
||||||
|
// arrays turn into pointers
|
||||||
|
assert(sizeof(({ array; }))==sizeof(char *));
|
||||||
|
assert(sizeof(array)==40);
|
||||||
|
|
||||||
|
// but it's not promotion
|
||||||
|
assert(sizeof(({ (char)1; }))==sizeof(char));
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
CORE
|
||||||
|
main.c
|
||||||
|
|
||||||
|
^EXIT=0$
|
||||||
|
^SIGNAL=0$
|
||||||
|
^VERIFICATION SUCCESSFUL$
|
||||||
|
--
|
|
@ -894,7 +894,7 @@ void c_typecheck_baset::typecheck_side_effect_statement_expression(
|
||||||
}
|
}
|
||||||
|
|
||||||
codet &code=to_code(expr.op0());
|
codet &code=to_code(expr.op0());
|
||||||
|
|
||||||
assert(code.get(ID_statement)==ID_block);
|
assert(code.get(ID_statement)==ID_block);
|
||||||
|
|
||||||
// the type is the type of the last statement in the
|
// the type is the type of the last statement in the
|
||||||
|
@ -930,10 +930,19 @@ void c_typecheck_baset::typecheck_side_effect_statement_expression(
|
||||||
if(last_statement==ID_expression)
|
if(last_statement==ID_expression)
|
||||||
{
|
{
|
||||||
assert(last->operands().size()==1);
|
assert(last->operands().size()==1);
|
||||||
expr.type()=last->op0().type();
|
exprt &op=last->op0();
|
||||||
|
|
||||||
|
// arrays here turn into pointers (array decay)
|
||||||
|
if(op.type().id()==ID_array)
|
||||||
|
implicit_typecast(op, pointer_typet(op.type().subtype()));
|
||||||
|
|
||||||
|
expr.type()=op.type();
|
||||||
}
|
}
|
||||||
else if(last_statement==ID_function_call)
|
else if(last_statement==ID_function_call)
|
||||||
{
|
{
|
||||||
|
// this is suspected to be dead
|
||||||
|
assert(false);
|
||||||
|
|
||||||
// make the last statement an expression
|
// make the last statement an expression
|
||||||
|
|
||||||
code_function_callt &fc=to_code_function_call(*last);
|
code_function_callt &fc=to_code_function_call(*last);
|
||||||
|
|
Loading…
Reference in New Issue