aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2017-11-21 06:14:32 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2017-11-21 06:14:32 +0000
commit5e43a9eeca114f99248c46495449d6fd4fc2b63e (patch)
tree24605dffe6f5f579e42b1ae2a63ea3acb543ff4d /gcc
parent8c098567886e155a07aabfeea764d5c67eadbdaf (diff)
downloadgcc-5e43a9eeca114f99248c46495449d6fd4fc2b63e.zip
gcc-5e43a9eeca114f99248c46495449d6fd4fc2b63e.tar.gz
gcc-5e43a9eeca114f99248c46495449d6fd4fc2b63e.tar.bz2
compiler: report error for ++/-- applied to a non-numeric type
This avoids a compiler crash. Fixes GCC PR 83071. Reviewed-on: https://go-review.googlesource.com/78875 From-SVN: r254983
Diffstat (limited to 'gcc')
-rw-r--r--gcc/go/gofrontend/MERGE2
-rw-r--r--gcc/go/gofrontend/statements.cc5
2 files changed, 6 insertions, 1 deletions
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index 4832c78..ed351c0 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -1,4 +1,4 @@
-cb5dc1ce98857884a2215c461dd1d7de530f9f5e
+5485b3faed476f6d051833d1790b5f77be9d1efc
The first line of this file holds the git revision number of the last
merge done from the gofrontend repository.
diff --git a/gcc/go/gofrontend/statements.cc b/gcc/go/gofrontend/statements.cc
index b22f690..e977980 100644
--- a/gcc/go/gofrontend/statements.cc
+++ b/gcc/go/gofrontend/statements.cc
@@ -1826,6 +1826,11 @@ Statement*
Inc_dec_statement::do_lower(Gogo*, Named_object*, Block*, Statement_inserter*)
{
Location loc = this->location();
+ if (!this->expr_->type()->is_numeric_type())
+ {
+ this->report_error("increment or decrement of non-numeric type");
+ return Statement::make_error_statement(loc);
+ }
Expression* oexpr = Expression::make_integer_ul(1, this->expr_->type(), loc);
Operator op = this->is_inc_ ? OPERATOR_PLUSEQ : OPERATOR_MINUSEQ;
return Statement::make_assignment_operation(op, this->expr_, oexpr, loc);