2009-12-16 04:14:24 +08:00
|
|
|
// RUN: %clang_cc1 %s -fsyntax-only -verify -pedantic
|
2008-05-19 02:08:51 +08:00
|
|
|
|
2009-02-08 03:52:04 +08:00
|
|
|
typedef struct S S; // expected-note 3 {{forward declaration of 'struct S'}}
|
2008-05-19 02:08:51 +08:00
|
|
|
void a(S* b, void* c) {
|
2009-01-23 08:36:41 +08:00
|
|
|
void (*fp)(int) = 0;
|
2011-06-27 16:02:19 +08:00
|
|
|
b++; // expected-error {{arithmetic on a pointer to an incomplete type}}
|
|
|
|
b += 1; // expected-error {{arithmetic on a pointer to an incomplete type}}
|
|
|
|
c++; // expected-warning {{arithmetic on a pointer to void is a GNU extension}}
|
|
|
|
c += 1; // expected-warning {{arithmetic on a pointer to void is a GNU extension}}
|
|
|
|
c--; // expected-warning {{arithmetic on a pointer to void is a GNU extension}}
|
|
|
|
c -= 1; // expected-warning {{arithmetic on a pointer to void is a GNU extension}}
|
2011-06-28 00:32:27 +08:00
|
|
|
(void) c[1]; // expected-warning {{subscript of a pointer to void is a GNU extension}}
|
2011-06-27 16:02:19 +08:00
|
|
|
b = 1+b; // expected-error {{arithmetic on a pointer to an incomplete type}}
|
2008-05-19 02:08:51 +08:00
|
|
|
/* The next couple tests are only pedantic warnings in gcc */
|
|
|
|
void (*d)(S*,void*) = a;
|
2011-06-27 16:02:19 +08:00
|
|
|
d += 1; // expected-warning {{arithmetic on a pointer to the function type 'void (S *, void *)' is a GNU extension}}
|
|
|
|
d++; // expected-warning {{arithmetic on a pointer to the function type 'void (S *, void *)' is a GNU extension}}
|
|
|
|
d--; // expected-warning {{arithmetic on a pointer to the function type 'void (S *, void *)' is a GNU extension}}
|
|
|
|
d -= 1; // expected-warning {{arithmetic on a pointer to the function type 'void (S *, void *)' is a GNU extension}}
|
|
|
|
(void)(1 + d); // expected-warning {{arithmetic on a pointer to the function type 'void (S *, void *)' is a GNU extension}}
|
2008-05-19 02:08:51 +08:00
|
|
|
}
|