* Go patch committed: check for ... with builtin functions
@ 2011-03-26 7:09 Ian Lance Taylor
0 siblings, 0 replies; only message in thread
From: Ian Lance Taylor @ 2011-03-26 7:09 UTC (permalink / raw)
To: gcc-patches, gofrontend-dev
[-- Attachment #1: Type: text/plain, Size: 327 bytes --]
The Go builtin functions other than append don't handle using ... to
pass a varargs argument. This patch to the gccgo frontend checks for
that. It also gives a better error message for an attempt to use
... with a type conversion. Bootstrapped and ran Go testsuite on
x86_64-unknown-linux-gnu. Committed to mainline.
Ian
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch --]
[-- Type: text/x-diff, Size: 1145 bytes --]
diff -r e304fc5e4c8c go/expressions.cc
--- a/go/expressions.cc Fri Mar 25 22:44:29 2011 -0700
+++ b/go/expressions.cc Fri Mar 25 23:02:05 2011 -0700
@@ -6672,6 +6672,12 @@
Expression*
Builtin_call_expression::do_lower(Gogo* gogo, Named_object* function, int)
{
+ if (this->is_varargs() && this->code_ != BUILTIN_APPEND)
+ {
+ this->report_error(_("invalid use of %<...%> with builtin function"));
+ return Expression::make_error(this->location());
+ }
+
if (this->code_ == BUILTIN_NEW)
{
const Expression_list* args = this->args();
diff -r e304fc5e4c8c go/parse.cc
--- a/go/parse.cc Fri Mar 25 22:44:29 2011 -0700
+++ b/go/parse.cc Fri Mar 25 23:02:05 2011 -0700
@@ -2705,6 +2705,12 @@
this->advance_token();
Expression* expr = this->expression(PRECEDENCE_NORMAL, false, true,
NULL);
+ if (this->peek_token()->is_op(OPERATOR_ELLIPSIS))
+ {
+ error_at(this->location(),
+ "invalid use of %<...%> in type conversion");
+ this->advance_token();
+ }
if (!this->peek_token()->is_op(OPERATOR_RPAREN))
error_at(this->location(), "expected %<)%>");
else
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2011-03-26 6:06 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-26 7:09 Go patch committed: check for ... with builtin functions 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).