1*a07aba5dSTimm Baeder // RUN: %clang_cc1 %s -fsyntax-only -verify=gnu,expected -pedantic -Wextra -std=c11 -fexperimental-new-constant-interpreter 2*a07aba5dSTimm Baeder // RUN: %clang_cc1 %s -fsyntax-only -triple i686-unknown-unknown -verify=gnu,expected -pedantic -Wextra -std=c11 -fexperimental-new-constant-interpreter 3*a07aba5dSTimm Baeder // RUN: %clang_cc1 %s -fsyntax-only -triple x86_64-unknown-unknown -verify=gnu,expected -pedantic -Wextra -std=c11 -fexperimental-new-constant-interpreter 4*a07aba5dSTimm Baeder // RUN: %clang_cc1 %s -fsyntax-only -verify -pedantic -Wextra -Wno-gnu -std=c11 -fexperimental-new-constant-interpreter 5*a07aba5dSTimm Baeder 6*a07aba5dSTimm Baeder typedef __INTPTR_TYPE__ intptr_t; 7*a07aba5dSTimm Baeder typedef struct S S; // expected-note 4 {{forward declaration of 'struct S'}} 8*a07aba5dSTimm Baeder extern _Atomic(S*) e; 9*a07aba5dSTimm Baeder void a(S* b, void* c) { 10*a07aba5dSTimm Baeder void (*fp)(int) = 0; 11*a07aba5dSTimm Baeder b++; // expected-error {{arithmetic on a pointer to an incomplete type}} 12*a07aba5dSTimm Baeder b += 1; // expected-error {{arithmetic on a pointer to an incomplete type}} 13*a07aba5dSTimm Baeder c++; // gnu-warning {{arithmetic on a pointer to void is a GNU extension}} 14*a07aba5dSTimm Baeder c += 1; // gnu-warning {{arithmetic on a pointer to void is a GNU extension}} 15*a07aba5dSTimm Baeder c--; // gnu-warning {{arithmetic on a pointer to void is a GNU extension}} 16*a07aba5dSTimm Baeder c -= 1; // gnu-warning {{arithmetic on a pointer to void is a GNU extension}} 17*a07aba5dSTimm Baeder (void) c[1]; // gnu-warning {{subscript of a pointer to void is a GNU extension}} 18*a07aba5dSTimm Baeder b = 1+b; // expected-error {{arithmetic on a pointer to an incomplete type}} 19*a07aba5dSTimm Baeder /* The next couple tests are only pedantic warnings in gcc */ 20*a07aba5dSTimm Baeder void (*d)(S*,void*) = a; 21*a07aba5dSTimm Baeder d += 1; // gnu-warning {{arithmetic on a pointer to the function type 'void (S *, void *)' (aka 'void (struct S *, void *)') is a GNU extension}} 22*a07aba5dSTimm Baeder d++; // gnu-warning {{arithmetic on a pointer to the function type 'void (S *, void *)' (aka 'void (struct S *, void *)') is a GNU extension}} 23*a07aba5dSTimm Baeder d--; // gnu-warning {{arithmetic on a pointer to the function type 'void (S *, void *)' (aka 'void (struct S *, void *)') is a GNU extension}} 24*a07aba5dSTimm Baeder d -= 1; // gnu-warning {{arithmetic on a pointer to the function type 'void (S *, void *)' (aka 'void (struct S *, void *)') is a GNU extension}} 25*a07aba5dSTimm Baeder (void)(1 + d); // gnu-warning {{arithmetic on a pointer to the function type 'void (S *, void *)' (aka 'void (struct S *, void *)') is a GNU extension}} 26*a07aba5dSTimm Baeder e++; // expected-error {{arithmetic on a pointer to an incomplete type}} 27*a07aba5dSTimm Baeder intptr_t i = (intptr_t)b; 28*a07aba5dSTimm Baeder char *f = (char*)0 + i; // gnu-warning {{arithmetic on a null pointer treated as a cast from integer to pointer is a GNU extension}} 29*a07aba5dSTimm Baeder // Cases that don't match the GNU inttoptr idiom get a different warning. 30*a07aba5dSTimm Baeder f = (char*)0 - i; // expected-warning {{performing pointer arithmetic on a null pointer has undefined behavior}} 31*a07aba5dSTimm Baeder int *g = (int*)0 + i; // expected-warning {{performing pointer arithmetic on a null pointer has undefined behavior}} 32*a07aba5dSTimm Baeder } 33