bug608752.c

来自「sdcc是为51等小型嵌入式cpu设计的c语言编译器支持数种不同类型的cpu」· C语言 代码 · 共 46 行

C
46
字号
/* OpAssign tests
 */
#include <testfwk.h>

#ifdef SDCC
#include <sdcc-lib.h>
#else
#define _STATMEM
#endif

typedef struct
{
  char a;
  char n;
} item_type;

item_type t;


_STATMEM item_type* get_next_item(void)
{
  /* have a side effect */
  t.n++;

  /* keep things easy, not implementing a list.
     Using a true list would break things
     even more pointedly:
     a) reading beyond end of the list and
     b) intermixing list members */
  return &t;
}


void
testOpAssign(void)
{
  t.a = 0;
  t.n = 0;

  /* get_next_item() should be called only once */
  get_next_item()->a |= 42;

  ASSERT (t.a == 42);
  ASSERT (t.n == 1);
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?