⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pointer-arith-2.c

📁 用于进行gcc测试
💻 C
字号:
/* Test diagnostics for arithmetic on void and function pointers.   Test with -Wpointer-arith.  *//* Origin: Joseph Myers <joseph@codesourcery.com> *//* { dg-do compile } *//* { dg-options "-Wpointer-arith" } */void *p;void (*f)(void);voidg (void){  p + 0; /* { dg-warning "pointer of type 'void \\*' used in arithmetic" } */  p + 1; /* { dg-warning "pointer of type 'void \\*' used in arithmetic" } */  0 + p; /* { dg-warning "pointer of type 'void \\*' used in arithmetic" } */  1 + p; /* { dg-warning "pointer of type 'void \\*' used in arithmetic" } */  p - 0; /* { dg-warning "pointer of type 'void \\*' used in arithmetic" } */  p - 1; /* { dg-warning "pointer of type 'void \\*' used in arithmetic" } */  p += 0; /* { dg-warning "pointer of type 'void \\*' used in arithmetic" } */  p += 1; /* { dg-warning "pointer of type 'void \\*' used in arithmetic" } */  p -= 0; /* { dg-warning "pointer of type 'void \\*' used in arithmetic" } */  p -= 1; /* { dg-warning "pointer of type 'void \\*' used in arithmetic" } */  f + 0; /* { dg-warning "pointer to a function used in arithmetic" } */  f + 1; /* { dg-warning "pointer to a function used in arithmetic" } */  0 + f; /* { dg-warning "pointer to a function used in arithmetic" } */  1 + f; /* { dg-warning "pointer to a function used in arithmetic" } */  f - 0; /* { dg-warning "pointer to a function used in arithmetic" } */  f - 1; /* { dg-warning "pointer to a function used in arithmetic" } */  f += 0; /* { dg-warning "pointer to a function used in arithmetic" } */  f += 1; /* { dg-warning "pointer to a function used in arithmetic" } */  f -= 0; /* { dg-warning "pointer to a function used in arithmetic" } */  f -= 1; /* { dg-warning "pointer to a function used in arithmetic" } */  p[0]; /* { dg-warning "dereferencing 'void \\*' pointer" } */  /* { dg-warning "pointer of type 'void \\*' used in arithmetic" "array 1" { target *-*-* } 33 } */  0[p]; /* { dg-warning "dereferencing 'void \\*' pointer" } */  /* { dg-warning "pointer of type 'void \\*' used in arithmetic" "array 1" { target *-*-* } 35 } */  f[0]; /* { dg-error "subscripted value is pointer to function" } */  0[f]; /* { dg-error "subscripted value is pointer to function" } */  p - p; /* { dg-warning "pointer of type 'void \\*' used in subtraction" } */  f - f; /* { dg-warning "pointer to a function used in subtraction" } */}

⌨️ 快捷键说明

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