bug-895992.c

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

C
61
字号
/* bug-895992.c   Life Range problem with   - uninitialized variable   - loop   - conditional block   LR problem hits all ports, but this test is mcs51 specific */#include <testfwk.h>char p0 = 2;unsigned short loops;static voidwait (void){  long i, j;  /* just clobber all registers: */  for (i = 0; i < 2; ++i)    for (j = 0; j < 2; ++j)      ;}#if !defined(PORT_HOST)#  pragma disable_warning 84#endifstatic voidtestLR(void){/* * excluded for pic16 due to bug: * [ 1511794 ] pic16: regression test bug-895992.c fails */#ifndef SDCC_pic16  unsigned char number;  unsigned char start = 1;  unsigned char i;  do    {      for (i = 1; i > 0 ; i--)        wait();         /* destroys all registers */      if (start)        {          number = p0;          start = 0;        }      number--;         /* 'number' might be used before initialization     */                        /* the life range of 'number' must be extended to   */                        /* the whole loop _including_ the conditional block */      ++loops;    }  while (number != 0);  ASSERT(loops == p0);#endif}

⌨️ 快捷键说明

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