x
authorJason Merrill <merrill@gnu.org>
Mon, 9 Jun 1997 23:41:21 +0000 (23:41 +0000)
committerJason Merrill <merrill@gnu.org>
Mon, 9 Jun 1997 23:41:21 +0000 (23:41 +0000)
From-SVN: r14210

gcc/fold-const.c

index 45311c91ed34347d9b695b4a463eb5b1c958e982..e8ef497176fa37773f2382dccb32fd777f53503c 100644 (file)
@@ -5498,14 +5498,21 @@ fold (expr)
                  return pedantic_non_lvalue (convert (type, arg1));
                case LE_EXPR:
                case LT_EXPR:
-                 return pedantic_non_lvalue
-                   (convert (type, (fold (build (MIN_EXPR, comp_type,
-                                                 comp_op0, comp_op1)))));
+                 /* In C++ a ?: expression can be an lvalue, so we can't
+                    do this; we would lose the distinction between
+                    LT and LE.  */
+                 if (pedantic_lvalues)
+                   return pedantic_non_lvalue
+                     (convert (type, (fold (build (MIN_EXPR, comp_type,
+                                                   comp_op0, comp_op1)))));
+                 break;
                case GE_EXPR:
                case GT_EXPR:
-                 return pedantic_non_lvalue
-                   (convert (type, fold (build (MAX_EXPR, comp_type,
-                                                comp_op0, comp_op1))));
+                 if (pedantic_lvalues)
+                   return pedantic_non_lvalue
+                     (convert (type, fold (build (MAX_EXPR, comp_type,
+                                                  comp_op0, comp_op1))));
+                 break;
                }
            }