Daniel Dunbar | a572887 | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 %s -fsyntax-only -verify -pedantic |
Eli Friedman | d72d16e | 2008-05-18 18:08:51 +0000 | [diff] [blame] | 2 | |
Sebastian Redl | 3cb0692 | 2009-02-07 19:52:04 +0000 | [diff] [blame] | 3 | typedef struct S S; // expected-note 3 {{forward declaration of 'struct S'}} |
Eli Friedman | d72d16e | 2008-05-18 18:08:51 +0000 | [diff] [blame] | 4 | void a(S* b, void* c) { |
Douglas Gregor | c983b86 | 2009-01-23 00:36:41 +0000 | [diff] [blame] | 5 | void (*fp)(int) = 0; |
Chandler Carruth | 13b21be | 2011-06-27 08:02:19 +0000 | [diff] [blame] | 6 | b++; // expected-error {{arithmetic on a pointer to an incomplete type}} |
| 7 | b += 1; // expected-error {{arithmetic on a pointer to an incomplete type}} |
| 8 | c++; // expected-warning {{arithmetic on a pointer to void is a GNU extension}} |
| 9 | c += 1; // expected-warning {{arithmetic on a pointer to void is a GNU extension}} |
| 10 | c--; // expected-warning {{arithmetic on a pointer to void is a GNU extension}} |
| 11 | c -= 1; // expected-warning {{arithmetic on a pointer to void is a GNU extension}} |
Chandler Carruth | 6628969 | 2011-06-27 16:32:27 +0000 | [diff] [blame] | 12 | (void) c[1]; // expected-warning {{subscript of a pointer to void is a GNU extension}} |
Chandler Carruth | 13b21be | 2011-06-27 08:02:19 +0000 | [diff] [blame] | 13 | b = 1+b; // expected-error {{arithmetic on a pointer to an incomplete type}} |
Eli Friedman | d72d16e | 2008-05-18 18:08:51 +0000 | [diff] [blame] | 14 | /* The next couple tests are only pedantic warnings in gcc */ |
| 15 | void (*d)(S*,void*) = a; |
Chandler Carruth | 13b21be | 2011-06-27 08:02:19 +0000 | [diff] [blame] | 16 | d += 1; // expected-warning {{arithmetic on a pointer to the function type 'void (S *, void *)' is a GNU extension}} |
| 17 | d++; // expected-warning {{arithmetic on a pointer to the function type 'void (S *, void *)' is a GNU extension}} |
| 18 | d--; // expected-warning {{arithmetic on a pointer to the function type 'void (S *, void *)' is a GNU extension}} |
| 19 | d -= 1; // expected-warning {{arithmetic on a pointer to the function type 'void (S *, void *)' is a GNU extension}} |
| 20 | (void)(1 + d); // expected-warning {{arithmetic on a pointer to the function type 'void (S *, void *)' is a GNU extension}} |
Eli Friedman | d72d16e | 2008-05-18 18:08:51 +0000 | [diff] [blame] | 21 | } |