public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Go patch committed: Fix parsing of send clauses with composite literals
@ 2014-12-16 18:58 Ian Lance Taylor
  0 siblings, 0 replies; only message in thread
From: Ian Lance Taylor @ 2014-12-16 18:58 UTC (permalink / raw)
  To: gcc-patches, gofrontend-dev

[-- Attachment #1: Type: text/plain, Size: 321 bytes --]

PR 61273 points out that "for ; false; c <- false {" doesn't parse
correctly.  It's because the "false {" is incorrectly interpreted as
being a potential composite literal.  This patch from Chris Manghane
fixes the parsing bug.  Bootstrapped and ran Go testsuite on
x86_64-unknown-linux-gnu.  Committed to mainline.

Ian

[-- Attachment #2: foo.txt --]
[-- Type: text/plain, Size: 1535 bytes --]

diff -r 670705a1c9cc go/parse.cc
--- a/go/parse.cc	Mon Dec 15 12:17:08 2014 -0800
+++ b/go/parse.cc	Tue Dec 16 10:50:34 2014 -0800
@@ -3819,7 +3819,7 @@
   token = this->peek_token();
   if (token->is_op(OPERATOR_CHANOP))
     {
-      this->send_stmt(this->verify_not_sink(exp));
+      this->send_stmt(this->verify_not_sink(exp), may_be_composite_lit);
       if (return_exp != NULL)
 	*return_exp = true;
     }
@@ -3913,13 +3913,13 @@
 // Channel  = Expression .
 
 void
-Parse::send_stmt(Expression* channel)
+Parse::send_stmt(Expression* channel, bool may_be_composite_lit)
 {
   go_assert(this->peek_token()->is_op(OPERATOR_CHANOP));
   Location loc = this->location();
   this->advance_token();
-  Expression* val = this->expression(PRECEDENCE_NORMAL, false, true, NULL,
-				     NULL);
+  Expression* val = this->expression(PRECEDENCE_NORMAL, false,
+				     may_be_composite_lit, NULL, NULL);
   Statement* s = Statement::make_send_statement(channel, val, loc);
   this->gogo_->add_statement(s);
 }
diff -r 670705a1c9cc go/parse.h
--- a/go/parse.h	Mon Dec 15 12:17:08 2014 -0800
+++ b/go/parse.h	Tue Dec 16 10:50:34 2014 -0800
@@ -245,7 +245,7 @@
   void statement_list();
   bool statement_list_may_start_here();
   void expression_stat(Expression*);
-  void send_stmt(Expression*);
+  void send_stmt(Expression*, bool may_be_composite_lit);
   void inc_dec_stat(Expression*);
   void assignment(Expression*, bool may_be_composite_lit, Range_clause*);
   void tuple_assignment(Expression_list*, bool may_be_composite_lit,

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2014-12-16 18:53 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-16 18:58 Go patch committed: Fix parsing of send clauses with composite literals Ian Lance Taylor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).