re PR c++/38064 ([c++0x] operator== doesn't work for enum classes)
authorJason Merrill <jason@redhat.com>
Tue, 4 May 2010 19:01:13 +0000 (15:01 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Tue, 4 May 2010 19:01:13 +0000 (15:01 -0400)
PR c++/38064
* typeck.c (cp_build_binary_op): Allow enums for <> as well.

From-SVN: r159042

gcc/cp/ChangeLog
gcc/cp/typeck.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/enum3.C

index 634a74b98347ddffe006c821665be1f8c3d8c23c..3f3b68ec34ab85386fa3405ea9bb3e2c6f74ebdc 100644 (file)
@@ -1,3 +1,8 @@
+2010-05-04  Jason Merrill  <jason@redhat.com>
+
+       PR c++/38064
+       * typeck.c (cp_build_binary_op): Allow enums for <> as well.
+
 2010-05-04  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR c++/43705
index 46bc34dbbb6e68f4e9dca91458ab87ac04c6503f..e92175f1d32532f37622667f5b774dbfe8862cb9 100644 (file)
@@ -4174,8 +4174,10 @@ cp_build_binary_op (location_t location,
        }
 
       build_type = boolean_type_node;
-      if ((code0 == INTEGER_TYPE || code0 == REAL_TYPE)
-          && (code1 == INTEGER_TYPE || code1 == REAL_TYPE))
+      if ((code0 == INTEGER_TYPE || code0 == REAL_TYPE
+          || code0 == ENUMERAL_TYPE)
+          && (code1 == INTEGER_TYPE || code1 == REAL_TYPE
+              || code1 == ENUMERAL_TYPE))
        short_compare = 1;
       else if (code0 == POINTER_TYPE && code1 == POINTER_TYPE)
        result_type = composite_pointer_type (type0, type1, op0, op1,
index 737a9f151e225e8a774abd581214ee81d15308e3..5b213ca82fdaf263f977709bc29b0bf6314ac395 100644 (file)
@@ -1,3 +1,8 @@
+2010-05-04  Jason Merrill  <jason@redhat.com>
+
+       PR c++/38064
+       * g++.dg/cpp0x/enum3.C: Extend.
+
 2010-05-04  H.J. Lu  <hongjiu.lu@intel.com>
 
        PR target/43799
index 5555ab2aac817e072b3a68fc757dcf5e9977d4f8..5ae5e1a9d664e08c7979a2651c26104ff5317371 100644 (file)
@@ -14,4 +14,14 @@ int main()
   E e = E::elem;
   if (!f (e == E::elem))
     return 1;
+  if (!f (e <= E::elem))
+    return 1;
+  if (!f (e >= E::elem))
+    return 1;
+  if (f (e < E::elem))
+    return 1;
+  if (f (e > E::elem))
+    return 1;
+  if (f (e != E::elem))
+    return 1;
 }