switch (code)
{
-/* 4 For every pair T, VQ), where T is an arithmetic or enumeration type,
+/* 4 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);
- 5 For every pair T, VQ), where T is an enumeration type or an arithmetic
- type other than bool, and VQ is either volatile or empty, there exist
- candidate operator functions of the form
+ 5 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);
- 6 For every pair T, VQ), where T is a cv-qualified or cv-unqualified
- complete object type, and VQ is either volatile or empty, there exist
- candidate operator functions of the form
+ 6 For every pair (T, VQ), where T is a cv-qualified or cv-unqualified object
+ type, and VQ is either volatile or empty, there exist candidate operator
+ functions of the form
T*VQ& operator++(T*VQ&);
T*VQ& operator--(T*VQ&);
T* operator++(T*VQ&, int);
/* FALLTHRU */
case POSTINCREMENT_EXPR:
case PREINCREMENT_EXPR:
+ /* P0002R1, Remove deprecated operator++(bool) added "other than bool"
+ to p4. */
+ if (TREE_CODE (type1) == BOOLEAN_TYPE && cxx_dialect >= cxx17)
+ return;
if (ARITHMETIC_TYPE_P (type1) || TYPE_PTROB_P (type1))
{
type1 = build_reference_type (type1);
--- /dev/null
+// { dg-do compile { target c++17 } }
+// Don't add built-in operator for ++ on bool.
+
+template<typename T>
+struct S { operator T&(); };
+
+template<int> void
+foo (S<bool>& s)
+{
+ --s; // { dg-error "no match for" }
+ ++s; // { dg-error "no match for" }
+ s++; // { dg-error "declared for postfix" }
+ s--; // { dg-error "declared for postfix" }
+}
+
+void
+bar ()
+{
+ S<bool> s;
+ foo<0> (s);
+}