diff options
author | Jan Korous <jkorous@apple.com> | 2018-04-18 13:38:39 +0000 |
---|---|---|
committer | Jan Korous <jkorous@apple.com> | 2018-04-18 13:38:39 +0000 |
commit | 536d2e30721e2b1690ac4018c033e36c096820bb (patch) | |
tree | 03707003da395d5fa2faa264afe3a18047adf3ee /clang/lib/Sema/SemaOverload.cpp | |
parent | d501a609c408530bbfe4a12fb3e5c1702a5de66a (diff) | |
download | bcm5719-llvm-536d2e30721e2b1690ac4018c033e36c096820bb.tar.gz bcm5719-llvm-536d2e30721e2b1690ac4018c033e36c096820bb.zip |
[Sema] Disable built-in increment operator for bool in overload resolution in C++17
Following: https://llvm.org/svn/llvm-project/cfe/trunk@329804
For C++17 the wording of [over.built] p4 excluded bool:
For every pair (T , vq), where T is an arithmetic type other than bool, there exist
candidate operator functions of the form
vq T & operator++(vq T &);
T operator++(vq T &, int);
Differential Revision: https://reviews.llvm.org/D45569
llvm-svn: 330254
Diffstat (limited to 'clang/lib/Sema/SemaOverload.cpp')
-rw-r--r-- | clang/lib/Sema/SemaOverload.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp index 9cce75c7197..64cd52c1f65 100644 --- a/clang/lib/Sema/SemaOverload.cpp +++ b/clang/lib/Sema/SemaOverload.cpp @@ -7782,11 +7782,13 @@ public: InitArithmeticTypes(); } + // Increment is deprecated for bool since C++17. + // // C++ [over.built]p3: // - // For every pair (T, VQ), where T is an arithmetic type, and VQ - // is either volatile or empty, there exist candidate operator - // functions of the form + // For every pair (T, VQ), where T is an arithmetic type other + // than bool, and VQ is either volatile or empty, there exist + // candidate operator functions of the form // // VQ T& operator++(VQ T&); // T operator++(VQ T&, int); @@ -7805,8 +7807,12 @@ public: for (unsigned Arith = 0; Arith < NumArithmeticTypes; ++Arith) { const auto TypeOfT = ArithmeticTypes[Arith]; - if (Op == OO_MinusMinus && TypeOfT == S.Context.BoolTy) - continue; + if (TypeOfT == S.Context.BoolTy) { + if (Op == OO_MinusMinus) + continue; + if (Op == OO_PlusPlus && S.getLangOpts().CPlusPlus17) + continue; + } addPlusPlusMinusMinusStyleOverloads( TypeOfT, VisibleTypeConversionsQuals.hasVolatile(), |