diff options
Diffstat (limited to 'test/Sema/pointer-addition.c')
-rw-r--r-- | test/Sema/pointer-addition.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/test/Sema/pointer-addition.c b/test/Sema/pointer-addition.c index c71e96114b8a..562f05340f7c 100644 --- a/test/Sema/pointer-addition.c +++ b/test/Sema/pointer-addition.c @@ -1,4 +1,8 @@ -// RUN: %clang_cc1 %s -fsyntax-only -verify -pedantic -std=c11 +// RUN: %clang_cc1 %s -fsyntax-only -verify -pedantic -Wextra -std=c11 +// RUN: %clang_cc1 %s -fsyntax-only -triple i686-unknown-unknown -verify -pedantic -Wextra -std=c11 +// RUN: %clang_cc1 %s -fsyntax-only -triple x86_64-unknown-unknown -verify -pedantic -Wextra -std=c11 + +#include <stdint.h> typedef struct S S; // expected-note 4 {{forward declaration of 'struct S'}} extern _Atomic(S*) e; @@ -20,4 +24,9 @@ void a(S* b, void* c) { d -= 1; // expected-warning {{arithmetic on a pointer to the function type 'void (S *, void *)' (aka 'void (struct S *, void *)') is a GNU extension}} (void)(1 + d); // expected-warning {{arithmetic on a pointer to the function type 'void (S *, void *)' (aka 'void (struct S *, void *)') is a GNU extension}} e++; // expected-error {{arithmetic on a pointer to an incomplete type}} + intptr_t i = (intptr_t)b; + char *f = (char*)0 + i; // expected-warning {{arithmetic on a null pointer treated as a cast from integer to pointer is a GNU extension}} + // Cases that don't match the GNU inttoptr idiom get a different warning. + f = (char*)0 - i; // expected-warning {{performing pointer arithmetic on a null pointer has undefined behavior}} + int *g = (int*)0 + i; // expected-warning {{performing pointer arithmetic on a null pointer has undefined behavior}} } |