Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / Sema / warn-sizeof-array-decay.c
blob1bf33e20ecad1cd7edebaef8e42fad10cf3ad488
1 // RUN: %clang_cc1 -fsyntax-only -verify %s
3 void f(int x) {
4 char foo[10];
5 int bar[20];
6 char qux[30];
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]'}}
13 // This is ptrdiff_t.
14 (void)sizeof(foo - qux); // no-warning
16 (void)sizeof(foo, x); // no-warning
17 (void)sizeof(x, foo); // expected-warning{{sizeof on pointer operation will return size of 'char *' instead of 'char[10]'}}