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:
kroening 2014-08-27 14:21:15 +00:00
parent c7d2e8523b
commit e25eaa2f92
4 changed files with 32 additions and 3 deletions

View File

@ -1,4 +1,4 @@
KNOWNBUG
CORE
main.c
^EXIT=0$

View File

@ -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));
}

View File

@ -0,0 +1,7 @@
CORE
main.c
^EXIT=0$
^SIGNAL=0$
^VERIFICATION SUCCESSFUL$
--

View File

@ -930,10 +930,19 @@ void c_typecheck_baset::typecheck_side_effect_statement_expression(
if(last_statement==ID_expression)
{
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)
{
// this is suspected to be dead
assert(false);
// make the last statement an expression
code_function_callt &fc=to_code_function_call(*last);