[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / Sema / pointer-subtraction.cpp
blob28063a1fea6ef79fd7b9c636185d649321bb8059
1 // RUN: %clang_cc1 %s -fsyntax-only -verify -pedantic -Wextra -std=c++11 -isystem %S/Inputs
2 // RUN: %clang_cc1 %s -fsyntax-only -verify -pedantic -Wnull-pointer-subtraction -std=c++11 -isystem %S/Inputs
3 // RUN: %clang_cc1 %s -fsyntax-only -verify -pedantic -Wextra -std=c++11 -isystem %S/Inputs -Wsystem-headers -DSYSTEM_WARNINGS
4 // RUN: %clang_cc1 %s -fsyntax-only -verify -pedantic -Wnull-pointer-subtraction -std=c++11 -isystem %S/Inputs -Wsystem-headers -DSYSTEM_WARNINGS
6 #include <pointer-subtraction.h>
8 void a() {
9 char *f = (char *)0;
10 f = (char *)((char *)0 - f); // expected-warning {{performing pointer subtraction with a null pointer may have undefined behavior}}
11 f = (char *)(f - (char *)0); // expected-warning {{performing pointer subtraction with a null pointer may have undefined behavior}}
12 f = (char *)((char *)0 - (char *)0); // valid in C++
14 if (1)
15 f = (char *)((char *)0 - f); // expected-warning {{performing pointer subtraction with a null pointer may have undefined behavior}}
16 else
17 f = (char *)((char *)0 - f);
19 if (0)
20 f = (char *)((char *)0 - f);
21 else
22 f = (char *)((char *)0 - f); // expected-warning {{performing pointer subtraction with a null pointer may have undefined behavior}}
24 #ifndef SYSTEM_WARNINGS
25 SYSTEM_MACRO(f);
26 #else
27 SYSTEM_MACRO(f); // expected-warning {{performing pointer subtraction with a null pointer may have undefined behavior}}
28 #endif