Benjamin Kramer | 52b2e70 | 2013-03-29 21:43:21 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify %s |
| 2 | |
| 3 | void 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-warning |
| 15 | |
| 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]'}} |
| 18 | } |