1 // RUN: %clang_cc1 %s -fsyntax-only -verify -pedantic -Wextra -std=c11 -isystem %S/Inputs
2 // RUN: %clang_cc1 %s -fsyntax-only -verify -pedantic -Wnull-pointer-subtraction -std=c11 -isystem %S/Inputs
3 // RUN: %clang_cc1 %s -fsyntax-only -verify -pedantic -Wextra -std=c11 -isystem %S/Inputs -Wsystem-headers -DSYSTEM_WARNINGS
4 // RUN: %clang_cc1 %s -fsyntax-only -verify -pedantic -Wnull-pointer-subtraction -std=c11 -isystem %S/Inputs -Wsystem-headers -DSYSTEM_WARNINGS
6 #include <pointer-subtraction.h>
10 f
= (char *)((char *)0 - f
); // expected-warning {{performing pointer subtraction with a null pointer has undefined behavior}}
11 f
= (char *)(f
- (char *)0); // expected-warning {{performing pointer subtraction with a null pointer has undefined behavior}}
12 f
= (char *)((char *)0 - (char *)0); // expected-warning {{performing pointer subtraction with a null pointer has undefined behavior}} expected-warning {{performing pointer subtraction with a null pointer has undefined behavior}}
15 f
= (char *)((char *)0 - f
); // expected-warning {{performing pointer subtraction with a null pointer has undefined behavior}}
17 f
= (char *)((char *)0 - f
);
20 f
= (char *)((char *)0 - f
);
22 f
= (char *)((char *)0 - f
); // expected-warning {{performing pointer subtraction with a null pointer has undefined behavior}}
24 #ifndef SYSTEM_WARNINGS
27 SYSTEM_MACRO(f
); // expected-warning {{performing pointer subtraction with a null pointer has undefined behavior}}