brintos

brintos / llvm-project-archived public Read only

0
0
Text · 848 B · 1bf33e2 Raw
19 lines · c
1// RUN: %clang_cc1 -fsyntax-only -verify %s2 3void f(int x) {4  char foo[10];5  int bar[20];6  char qux[30];7 8  (void)sizeof(bar + 10); // expected-warning{{sizeof on pointer operation will return size of 'int *' instead of 'int[20]'}}9  (void)sizeof(foo - 20); // expected-warning{{sizeof on pointer operation will return size of 'char *' instead of 'char[10]'}}10  (void)sizeof(bar - x); // expected-warning{{sizeof on pointer operation will return size of 'int *' instead of 'int[20]'}}11  (void)sizeof(foo + x); // expected-warning{{sizeof on pointer operation will return size of 'char *' instead of 'char[10]'}}12 13  // This is ptrdiff_t.14  (void)sizeof(foo - qux); // no-warning15 16  (void)sizeof(foo, x); // no-warning17  (void)sizeof(x, foo); // expected-warning{{sizeof on pointer operation will return size of 'char *' instead of 'char[10]'}}18}19