Skip to content

Commit b32e3e1

Browse files
committed
[Clang] Add -fwrapv-pointer flag
GCC supports three flags related to overflow behavior: * `-fwrapv`: Makes signed integer overflow well-defined. * `-fwrapv-pointer`: Makes pointer overflow well-defined. * `-fno-strict-overflow`: Implies `-fwrapv -fwrapv-pointer`, making both signed integer overflow and pointer overflow well-defined. Clang currently only supports `-fno-strict-overflow` and `-fwrapv`, but not `-fwrapv-pointer`. This PR proposes to introduce `-fwrapv-pointer` and adjust the semantics of `-fwrapv` to match GCC. This allows signed integer overflow and pointer overflow to be controlled independently, while `-fno-strict-overflow` still exists to control both at the same time (and that option is consistent across GCC and Clang).
1 parent c39500f commit b32e3e1

File tree

14 files changed

+85
-39
lines changed

14 files changed

+85
-39
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@ code bases.
5858
containing strict-aliasing violations. The new default behavior can be
5959
disabled using ``-fno-pointer-tbaa``.
6060

61+
- The ``-fwrapv`` flag now only makes signed integer overflow well-defined,
62+
without affecting pointer overflow, which is controlled by a new
63+
``-fwrapv-pointer`` flag. The ``-fno-strict-overflow`` flag now implies
64+
both ``-fwrapv`` and ``-fwrapv-pointer`` and as such retains its old meaning.
65+
The new behavior matches GCC.
66+
6167
C/C++ Language Potentially Breaking Changes
6268
-------------------------------------------
6369

@@ -464,6 +470,11 @@ New Compiler Flags
464470
- clang-cl and clang-dxc now support ``-fdiagnostics-color=[auto|never|always]``
465471
in addition to ``-f[no-]color-diagnostics``.
466472

473+
- The new ``-fwrapv-pointer`` flag opts-in to a language dialect where pointer
474+
overflow is well-defined. The ``-fwrapv`` flag previously implied
475+
``-fwrapv-pointer`` as well, but no longer does. ``-fno-strict-overflow``
476+
implies ``-fwrapv -fwrapv-pointer``. The flags now match GCC.
477+
467478
Deprecated Compiler Flags
468479
-------------------------
469480

clang/include/clang/Basic/LangOptions.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,7 @@ VALUE_LANGOPT(TrivialAutoVarInitMaxSize, 32, 0,
407407
"stop trivial automatic variable initialization if var size exceeds the specified size (in bytes). Must be greater than 0.")
408408
ENUM_LANGOPT(SignedOverflowBehavior, SignedOverflowBehaviorTy, 2, SOB_Undefined,
409409
"signed integer overflow handling")
410+
LANGOPT(PointerOverflowDefined, 1, 0, "make pointer overflow defined")
410411
ENUM_LANGOPT(ThreadModel , ThreadModelKind, 2, ThreadModelKind::POSIX, "Thread Model")
411412

412413
BENIGN_LANGOPT(ArrowDepth, 32, 256,

clang/include/clang/Driver/Options.td

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4291,6 +4291,11 @@ def fwrapv : Flag<["-"], "fwrapv">, Group<f_Group>,
42914291
HelpText<"Treat signed integer overflow as two's complement">;
42924292
def fno_wrapv : Flag<["-"], "fno-wrapv">, Group<f_Group>,
42934293
Visibility<[ClangOption, CLOption, FlangOption]>;
4294+
def fwrapv_pointer : Flag<["-"], "fwrapv-pointer">, Group<f_Group>,
4295+
Visibility<[ClangOption, CLOption, CC1Option, FlangOption, FC1Option]>,
4296+
HelpText<"Treat pointer overflow as two's complement">;
4297+
def fno_wrapv_pointer : Flag<["-"], "fno-wrapv-pointer">, Group<f_Group>,
4298+
Visibility<[ClangOption, CLOption, FlangOption]>;
42944299
def fwritable_strings : Flag<["-"], "fwritable-strings">, Group<f_Group>,
42954300
Visibility<[ClangOption, CC1Option]>,
42964301
HelpText<"Store string literals as writable data">,

clang/lib/CodeGen/CGBuiltin.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22113,7 +22113,7 @@ RValue CodeGenFunction::EmitBuiltinAlignTo(const CallExpr *E, bool AlignUp) {
2211322113
// By adding the mask, we ensure that align_up on an already aligned
2211422114
// value will not change the value.
2211522115
if (Args.Src->getType()->isPointerTy()) {
22116-
if (getLangOpts().isSignedOverflowDefined())
22116+
if (getLangOpts().PointerOverflowDefined)
2211722117
SrcForMask =
2211822118
Builder.CreateGEP(Int8Ty, SrcForMask, Args.Mask, "over_boundary");
2211922119
else

clang/lib/CodeGen/CGExpr.cpp

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4307,14 +4307,14 @@ LValue CodeGenFunction::EmitArraySubscriptExpr(const ArraySubscriptExpr *E,
43074307
// GEP indexes are signed, and scaling an index isn't permitted to
43084308
// signed-overflow, so we use the same semantics for our explicit
43094309
// multiply. We suppress this if overflow is not undefined behavior.
4310-
if (getLangOpts().isSignedOverflowDefined()) {
4310+
if (getLangOpts().PointerOverflowDefined) {
43114311
Idx = Builder.CreateMul(Idx, numElements);
43124312
} else {
43134313
Idx = Builder.CreateNSWMul(Idx, numElements);
43144314
}
43154315

43164316
Addr = emitArraySubscriptGEP(*this, Addr, Idx, vla->getElementType(),
4317-
!getLangOpts().isSignedOverflowDefined(),
4317+
!getLangOpts().PointerOverflowDefined,
43184318
SignedIndices, E->getExprLoc());
43194319

43204320
} else if (const ObjCObjectType *OIT = E->getType()->getAs<ObjCObjectType>()){
@@ -4404,7 +4404,7 @@ LValue CodeGenFunction::EmitArraySubscriptExpr(const ArraySubscriptExpr *E,
44044404
QualType arrayType = Array->getType();
44054405
Addr = emitArraySubscriptGEP(
44064406
*this, ArrayLV.getAddress(), {CGM.getSize(CharUnits::Zero()), Idx},
4407-
E->getType(), !getLangOpts().isSignedOverflowDefined(), SignedIndices,
4407+
E->getType(), !getLangOpts().PointerOverflowDefined, SignedIndices,
44084408
E->getExprLoc(), &arrayType, E->getBase());
44094409
EltBaseInfo = ArrayLV.getBaseInfo();
44104410
EltTBAAInfo = CGM.getTBAAInfoForSubobject(ArrayLV, E->getType());
@@ -4413,10 +4413,9 @@ LValue CodeGenFunction::EmitArraySubscriptExpr(const ArraySubscriptExpr *E,
44134413
Addr = EmitPointerWithAlignment(E->getBase(), &EltBaseInfo, &EltTBAAInfo);
44144414
auto *Idx = EmitIdxAfterBase(/*Promote*/true);
44154415
QualType ptrType = E->getBase()->getType();
4416-
Addr = emitArraySubscriptGEP(*this, Addr, Idx, E->getType(),
4417-
!getLangOpts().isSignedOverflowDefined(),
4418-
SignedIndices, E->getExprLoc(), &ptrType,
4419-
E->getBase());
4416+
Addr = emitArraySubscriptGEP(
4417+
*this, Addr, Idx, E->getType(), !getLangOpts().PointerOverflowDefined,
4418+
SignedIndices, E->getExprLoc(), &ptrType, E->getBase());
44204419
}
44214420

44224421
LValue LV = MakeAddrLValue(Addr, E->getType(), EltBaseInfo, EltTBAAInfo);
@@ -4561,11 +4560,11 @@ LValue CodeGenFunction::EmitArraySectionExpr(const ArraySectionExpr *E,
45614560
: llvm::ConstantInt::get(IntPtrTy, ConstLength);
45624561
Idx = Builder.CreateAdd(LowerBoundVal, LengthVal, "lb_add_len",
45634562
/*HasNUW=*/false,
4564-
!getLangOpts().isSignedOverflowDefined());
4563+
!getLangOpts().PointerOverflowDefined);
45654564
if (Length && LowerBound) {
45664565
Idx = Builder.CreateSub(
45674566
Idx, llvm::ConstantInt::get(IntPtrTy, /*V=*/1), "idx_sub_1",
4568-
/*HasNUW=*/false, !getLangOpts().isSignedOverflowDefined());
4567+
/*HasNUW=*/false, !getLangOpts().PointerOverflowDefined);
45694568
}
45704569
} else
45714570
Idx = llvm::ConstantInt::get(IntPtrTy, ConstLength + ConstLowerBound);
@@ -4591,7 +4590,7 @@ LValue CodeGenFunction::EmitArraySectionExpr(const ArraySectionExpr *E,
45914590
Length->getType()->hasSignedIntegerRepresentation());
45924591
Idx = Builder.CreateSub(
45934592
LengthVal, llvm::ConstantInt::get(IntPtrTy, /*V=*/1), "len_sub_1",
4594-
/*HasNUW=*/false, !getLangOpts().isSignedOverflowDefined());
4593+
/*HasNUW=*/false, !getLangOpts().PointerOverflowDefined);
45954594
} else {
45964595
ConstLength = ConstLength.zextOrTrunc(PointerWidthInBits);
45974596
--ConstLength;
@@ -4618,12 +4617,12 @@ LValue CodeGenFunction::EmitArraySectionExpr(const ArraySectionExpr *E,
46184617
// GEP indexes are signed, and scaling an index isn't permitted to
46194618
// signed-overflow, so we use the same semantics for our explicit
46204619
// multiply. We suppress this if overflow is not undefined behavior.
4621-
if (getLangOpts().isSignedOverflowDefined())
4620+
if (getLangOpts().PointerOverflowDefined)
46224621
Idx = Builder.CreateMul(Idx, NumElements);
46234622
else
46244623
Idx = Builder.CreateNSWMul(Idx, NumElements);
46254624
EltPtr = emitArraySubscriptGEP(*this, Base, Idx, VLA->getElementType(),
4626-
!getLangOpts().isSignedOverflowDefined(),
4625+
!getLangOpts().PointerOverflowDefined,
46274626
/*signedIndices=*/false, E->getExprLoc());
46284627
} else if (const Expr *Array = isSimpleArrayDecayOperand(E->getBase())) {
46294628
// If this is A[i] where A is an array, the frontend will have decayed the
@@ -4643,7 +4642,7 @@ LValue CodeGenFunction::EmitArraySectionExpr(const ArraySectionExpr *E,
46434642
// Propagate the alignment from the array itself to the result.
46444643
EltPtr = emitArraySubscriptGEP(
46454644
*this, ArrayLV.getAddress(), {CGM.getSize(CharUnits::Zero()), Idx},
4646-
ResultExprTy, !getLangOpts().isSignedOverflowDefined(),
4645+
ResultExprTy, !getLangOpts().PointerOverflowDefined,
46474646
/*signedIndices=*/false, E->getExprLoc());
46484647
BaseInfo = ArrayLV.getBaseInfo();
46494648
TBAAInfo = CGM.getTBAAInfoForSubobject(ArrayLV, ResultExprTy);
@@ -4652,7 +4651,7 @@ LValue CodeGenFunction::EmitArraySectionExpr(const ArraySectionExpr *E,
46524651
emitOMPArraySectionBase(*this, E->getBase(), BaseInfo, TBAAInfo, BaseTy,
46534652
ResultExprTy, IsLowerBound);
46544653
EltPtr = emitArraySubscriptGEP(*this, Base, Idx, ResultExprTy,
4655-
!getLangOpts().isSignedOverflowDefined(),
4654+
!getLangOpts().PointerOverflowDefined,
46564655
/*signedIndices=*/false, E->getExprLoc());
46574656
}
46584657

clang/lib/CodeGen/CGExprScalar.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3037,7 +3037,7 @@ ScalarExprEmitter::EmitScalarPrePostIncDec(const UnaryOperator *E, LValue LV,
30373037
llvm::Value *numElts = CGF.getVLASize(vla).NumElts;
30383038
if (!isInc) numElts = Builder.CreateNSWNeg(numElts, "vla.negsize");
30393039
llvm::Type *elemTy = CGF.ConvertTypeForMem(vla->getElementType());
3040-
if (CGF.getLangOpts().isSignedOverflowDefined())
3040+
if (CGF.getLangOpts().PointerOverflowDefined)
30413041
value = Builder.CreateGEP(elemTy, value, numElts, "vla.inc");
30423042
else
30433043
value = CGF.EmitCheckedInBoundsGEP(
@@ -3048,7 +3048,7 @@ ScalarExprEmitter::EmitScalarPrePostIncDec(const UnaryOperator *E, LValue LV,
30483048
} else if (type->isFunctionType()) {
30493049
llvm::Value *amt = Builder.getInt32(amount);
30503050

3051-
if (CGF.getLangOpts().isSignedOverflowDefined())
3051+
if (CGF.getLangOpts().PointerOverflowDefined)
30523052
value = Builder.CreateGEP(CGF.Int8Ty, value, amt, "incdec.funcptr");
30533053
else
30543054
value =
@@ -3060,7 +3060,7 @@ ScalarExprEmitter::EmitScalarPrePostIncDec(const UnaryOperator *E, LValue LV,
30603060
} else {
30613061
llvm::Value *amt = Builder.getInt32(amount);
30623062
llvm::Type *elemTy = CGF.ConvertTypeForMem(type);
3063-
if (CGF.getLangOpts().isSignedOverflowDefined())
3063+
if (CGF.getLangOpts().PointerOverflowDefined)
30643064
value = Builder.CreateGEP(elemTy, value, amt, "incdec.ptr");
30653065
else
30663066
value = CGF.EmitCheckedInBoundsGEP(
@@ -3173,7 +3173,7 @@ ScalarExprEmitter::EmitScalarPrePostIncDec(const UnaryOperator *E, LValue LV,
31733173
llvm::Value *sizeValue =
31743174
llvm::ConstantInt::get(CGF.SizeTy, size.getQuantity());
31753175

3176-
if (CGF.getLangOpts().isSignedOverflowDefined())
3176+
if (CGF.getLangOpts().PointerOverflowDefined)
31773177
value = Builder.CreateGEP(CGF.Int8Ty, value, sizeValue, "incdec.objptr");
31783178
else
31793179
value = CGF.EmitCheckedInBoundsGEP(
@@ -4067,7 +4067,7 @@ static Value *emitPointerArithmetic(CodeGenFunction &CGF,
40674067
// signed-overflow, so we use the same semantics for our explicit
40684068
// multiply. We suppress this if overflow is not undefined behavior.
40694069
llvm::Type *elemTy = CGF.ConvertTypeForMem(vla->getElementType());
4070-
if (CGF.getLangOpts().isSignedOverflowDefined()) {
4070+
if (CGF.getLangOpts().PointerOverflowDefined) {
40714071
index = CGF.Builder.CreateMul(index, numElements, "vla.index");
40724072
pointer = CGF.Builder.CreateGEP(elemTy, pointer, index, "add.ptr");
40734073
} else {
@@ -4088,7 +4088,7 @@ static Value *emitPointerArithmetic(CodeGenFunction &CGF,
40884088
else
40894089
elemTy = CGF.ConvertTypeForMem(elementType);
40904090

4091-
if (CGF.getLangOpts().isSignedOverflowDefined())
4091+
if (CGF.getLangOpts().PointerOverflowDefined)
40924092
return CGF.Builder.CreateGEP(elemTy, pointer, index, "add.ptr");
40934093

40944094
return CGF.EmitCheckedInBoundsGEP(

clang/lib/Driver/SanitizerArgs.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -575,6 +575,9 @@ SanitizerArgs::SanitizerArgs(const ToolChain &TC,
575575
options::OPT_fstrict_overflow, false);
576576
if (Args.hasFlagNoClaim(options::OPT_fwrapv, options::OPT_fno_wrapv, S))
577577
Add &= ~SanitizerKind::SignedIntegerOverflow;
578+
if (Args.hasFlagNoClaim(options::OPT_fwrapv_pointer,
579+
options::OPT_fno_wrapv_pointer, S))
580+
Add &= ~SanitizerKind::PointerOverflow;
578581
}
579582
Add &= Supported;
580583

clang/lib/Driver/ToolChains/CommonArgs.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3106,12 +3106,19 @@ void tools::renderCommonIntegerOverflowOptions(const ArgList &Args,
31063106
ArgStringList &CmdArgs) {
31073107
// -fno-strict-overflow implies -fwrapv if it isn't disabled, but
31083108
// -fstrict-overflow won't turn off an explicitly enabled -fwrapv.
3109+
bool StrictOverflow = Args.hasFlag(options::OPT_fstrict_overflow,
3110+
options::OPT_fno_strict_overflow, true);
31093111
if (Arg *A = Args.getLastArg(options::OPT_fwrapv, options::OPT_fno_wrapv)) {
31103112
if (A->getOption().matches(options::OPT_fwrapv))
31113113
CmdArgs.push_back("-fwrapv");
3112-
} else if (Arg *A = Args.getLastArg(options::OPT_fstrict_overflow,
3113-
options::OPT_fno_strict_overflow)) {
3114-
if (A->getOption().matches(options::OPT_fno_strict_overflow))
3115-
CmdArgs.push_back("-fwrapv");
3114+
} else if (!StrictOverflow) {
3115+
CmdArgs.push_back("-fwrapv");
3116+
}
3117+
if (Arg *A = Args.getLastArg(options::OPT_fwrapv_pointer,
3118+
options::OPT_fno_wrapv_pointer)) {
3119+
if (A->getOption().matches(options::OPT_fwrapv_pointer))
3120+
CmdArgs.push_back("-fwrapv-pointer");
3121+
} else if (!StrictOverflow) {
3122+
CmdArgs.push_back("-fwrapv-pointer");
31163123
}
31173124
}

clang/lib/Frontend/CompilerInvocation.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3721,6 +3721,8 @@ void CompilerInvocationBase::GenerateLangArgs(const LangOptions &Opts,
37213721
} else if (Opts.SignedOverflowBehavior == LangOptions::SOB_Defined) {
37223722
GenerateArg(Consumer, OPT_fwrapv);
37233723
}
3724+
if (Opts.PointerOverflowDefined)
3725+
GenerateArg(Consumer, OPT_fwrapv_pointer);
37243726

37253727
if (Opts.MSCompatibilityVersion != 0) {
37263728
unsigned Major = Opts.MSCompatibilityVersion / 10000000;
@@ -4138,6 +4140,8 @@ bool CompilerInvocation::ParseLangArgs(LangOptions &Opts, ArgList &Args,
41384140
}
41394141
else if (Args.hasArg(OPT_fwrapv))
41404142
Opts.setSignedOverflowBehavior(LangOptions::SOB_Defined);
4143+
if (Args.hasArg(OPT_fwrapv_pointer))
4144+
Opts.PointerOverflowDefined = true;
41414145

41424146
Opts.MSCompatibilityVersion = 0;
41434147
if (const Arg *A = Args.getLastArg(OPT_fms_compatibility_version)) {

clang/lib/Sema/SemaExpr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11787,7 +11787,7 @@ static std::optional<bool> isTautologicalBoundsCheck(Sema &S, const Expr *LHS,
1178711787
const Expr *RHS,
1178811788
BinaryOperatorKind Opc) {
1178911789
if (!LHS->getType()->isPointerType() ||
11790-
S.getLangOpts().isSignedOverflowDefined())
11790+
S.getLangOpts().PointerOverflowDefined)
1179111791
return std::nullopt;
1179211792

1179311793
// Canonicalize to >= or < predicate.

clang/test/CodeGen/integer-overflow.c

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// RUN: %clang_cc1 -triple x86_64-apple-darwin %s -emit-llvm -o - | FileCheck %s --check-prefix=DEFAULT
22
// RUN: %clang_cc1 -triple x86_64-apple-darwin %s -emit-llvm -o - -fwrapv | FileCheck %s --check-prefix=WRAPV
33
// RUN: %clang_cc1 -triple x86_64-apple-darwin %s -emit-llvm -o - -ftrapv | FileCheck %s --check-prefix=TRAPV
4-
// RUN: %clang_cc1 -triple x86_64-apple-darwin %s -emit-llvm -o - -fsanitize=signed-integer-overflow | FileCheck %s --check-prefixes=CATCH_UB,CATCH_UB_POINTER
5-
// RUN: %clang_cc1 -triple x86_64-apple-darwin %s -emit-llvm -o - -fsanitize=signed-integer-overflow -fwrapv | FileCheck %s --check-prefixes=CATCH_UB,NOCATCH_UB_POINTER
4+
// RUN: %clang_cc1 -triple x86_64-apple-darwin %s -emit-llvm -o - -fsanitize=signed-integer-overflow | FileCheck %s --check-prefixes=CATCH_UB
5+
// RUN: %clang_cc1 -triple x86_64-apple-darwin %s -emit-llvm -o - -fsanitize=signed-integer-overflow -fwrapv | FileCheck %s --check-prefixes=CATCH_UB
66
// RUN: %clang_cc1 -triple x86_64-apple-darwin %s -emit-llvm -o - -ftrapv -ftrapv-handler foo | FileCheck %s --check-prefix=TRAPV_HANDLER
77

88

@@ -57,15 +57,6 @@ void test1(void) {
5757
// TRAPV_HANDLER: foo(
5858
--a;
5959

60-
// -fwrapv should turn off inbounds for GEP's, PR9256
61-
extern int* P;
62-
++P;
63-
// DEFAULT: getelementptr inbounds nuw i32, ptr
64-
// WRAPV: getelementptr i32, ptr
65-
// TRAPV: getelementptr inbounds nuw i32, ptr
66-
// CATCH_UB_POINTER: getelementptr inbounds nuw i32, ptr
67-
// NOCATCH_UB_POINTER: getelementptr i32, ptr
68-
6960
// PR9350: char pre-increment never overflows.
7061
extern volatile signed char PR9350_char_inc;
7162
// DEFAULT: add i8 {{.*}}, 1

clang/test/CodeGen/pointer-overflow.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// RUN: %clang_cc1 -triple x86_64-apple-darwin %s -emit-llvm -o - | FileCheck %s --check-prefix=DEFAULT
2+
// RUN: %clang_cc1 -triple x86_64-apple-darwin %s -emit-llvm -o - -fwrapv | FileCheck %s --check-prefix=DEFAULT
3+
// RUN: %clang_cc1 -triple x86_64-apple-darwin %s -emit-llvm -o - -ftrapv | FileCheck %s --check-prefix=DEFAULT
4+
// RUN: %clang_cc1 -triple x86_64-apple-darwin %s -emit-llvm -o - -fwrapv-pointer | FileCheck %s --check-prefix=FWRAPV-POINTER
5+
6+
void test(void) {
7+
// -fwrapv-pointer should turn off inbounds for GEP's
8+
extern int* P;
9+
++P;
10+
// DEFAULT: getelementptr inbounds nuw i32, ptr
11+
// FWRAPV-POINTER: getelementptr i32, ptr
12+
}

clang/test/Driver/clang_wrapv_opts.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,24 @@
11
// RUN: %clang -### -S -fwrapv -fno-wrapv -fwrapv %s 2>&1 | FileCheck -check-prefix=CHECK1 %s
22
// CHECK1: -fwrapv
33
//
4+
// RUN: %clang -### -S -fwrapv-pointer -fno-wrapv-pointer -fwrapv-pointer %s 2>&1 | FileCheck -check-prefix=CHECK1-POINTER %s
5+
// CHECK1-POINTER: -fwrapv-pointer
6+
//
47
// RUN: %clang -### -S -fstrict-overflow -fno-strict-overflow %s 2>&1 | FileCheck -check-prefix=CHECK2 %s
5-
// CHECK2: -fwrapv
8+
// CHECK2: -fwrapv{{.*}}-fwrapv-pointer
69
//
710
// RUN: %clang -### -S -fwrapv -fstrict-overflow %s 2>&1 | FileCheck -check-prefix=CHECK3 %s
811
// CHECK3: -fwrapv
912
//
13+
// RUN: %clang -### -S -fwrapv-pointer -fstrict-overflow %s 2>&1 | FileCheck -check-prefix=CHECK3-POINTER %s
14+
// CHECK3-POINTER: -fwrapv-pointer
15+
//
1016
// RUN: %clang -### -S -fno-wrapv -fno-strict-overflow %s 2>&1 | FileCheck -check-prefix=CHECK4 %s
1117
// CHECK4-NOT: -fwrapv
18+
// CHECK4: -fwrapv-pointer
19+
// CHECK4-NOT: -fwrapv
20+
//
21+
// RUN: %clang -### -S -fno-wrapv-pointer -fno-strict-overflow %s 2>&1 | FileCheck -check-prefix=CHECK4-POINTER %s
22+
// CHECK4-POINTER-NOT: -fwrapv-pointer
23+
// CHECK4-POINTER: -fwrapv
24+
// CHECK4-POINTER-NOT: -fwrapv-pointer

clang/test/Sema/tautological-pointer-comparison.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// RUN: %clang_cc1 -fsyntax-only -verify %s
2-
// RUN: %clang_cc1 -fsyntax-only -fwrapv -verify=fwrapv %s
2+
// RUN: %clang_cc1 -fsyntax-only -fwrapv-pointer -verify=fwrapv %s
33

44
// fwrapv-no-diagnostics
55

0 commit comments

Comments
 (0)