cleanup-3.c

来自「linux下编程用 编译软件」· C语言 代码 · 共 46 行

C
46
字号
/* { dg-do run } *//* { dg-options "" } *//* Verify that the cleanup handler receives the proper contents   of the variable.  */extern void exit(int);extern void abort(void);static int expected;static voidhandler(int *p){  if (*p != expected)    abort ();}static void __attribute__((noinline))bar(void){}static void doit(int x, int y){  int r __attribute__((cleanup (handler)));  if (x < y)    {      r = 0;      return;    }  bar();  r = x + y;}int main(){  expected = 0;  doit (1, 2);  expected = 3;  doit (2, 1);  return 0;}

⌨️ 快捷键说明

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