This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Go patch committed: Don't permit !0


This patch from RÃmy Oudompheng fixes a bug in the Go frontend: it was
permitting the ! unary operator with integer operands, but in the Go
language ! is only permitted with boolean operands.  Bootstrapped and
ran Go testsuite on x86_64-unknown-linux-gnu.  Committed to mainline and
4.7 branch.

Ian

diff -r 838f1f13015d go/expressions.cc
--- a/go/expressions.cc	Fri May 04 12:30:49 2012 -0700
+++ b/go/expressions.cc	Mon May 07 11:19:42 2012 -0700
@@ -3606,8 +3606,7 @@
       return Expression::make_error(this->location());
     }
 
-  if (op == OPERATOR_PLUS || op == OPERATOR_MINUS
-      || op == OPERATOR_NOT || op == OPERATOR_XOR)
+  if (op == OPERATOR_PLUS || op == OPERATOR_MINUS || op == OPERATOR_XOR)
     {
       Numeric_constant nc;
       if (expr->numeric_constant_value(&nc))
@@ -3697,10 +3696,10 @@
       else
 	go_unreachable();
 
+    case OPERATOR_XOR:
+      break;
+
     case OPERATOR_NOT:
-    case OPERATOR_XOR:
-      break;
-
     case OPERATOR_AND:
     case OPERATOR_MULT:
       return false;
@@ -3911,6 +3910,10 @@
       break;
 
     case OPERATOR_NOT:
+      if (!type->is_boolean_type())
+	this->report_error(_("expected boolean type"));
+      break;
+
     case OPERATOR_XOR:
       if (type->integer_type() == NULL
 	  && !type->is_boolean_type())

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]