Patchwork [gccgo] Expect a type after an erroneous ellipsis

login
register
mail settings
Submitter Ian Taylor
Date Aug. 31, 2010, 9:15 p.m.
Message ID <mcrwrr6cwmh.fsf@google.com>
Download mbox | patch
Permalink /patch/63319/
State New
Headers show

Comments

Ian Taylor - Aug. 31, 2010, 9:15 p.m.
A type will normally follow an ellipsis in a function definition.  When
an ellipsis is erroneously used with two parameters, the code was not
looking for the type.  This caused it spew some useless error messages.
This patch makes it look for the type.  Committed to gccgo branch.

Ian

Patch

Index: gcc/go/parse.cc
===================================================================
--- gcc/go/parse.cc	(revision 163575)
+++ gcc/go/parse.cc	(working copy)
@@ -818,7 +818,7 @@  Parse::parameter_list(bool* is_varargs)
 		{
 		  this->error("%<...%> only permits one name");
 		  this->advance_token();
-		  type = Type::make_error_type();
+		  type = this->type();
 		}
 	      for (size_t i = 0; i < ret->size(); ++i)
 		ret->set_type(i, type);
Index: gcc/testsuite/go.test/test/fixedbugs/bug228.go
===================================================================
--- gcc/testsuite/go.test/test/fixedbugs/bug228.go	(revision 163682)
+++ gcc/testsuite/go.test/test/fixedbugs/bug228.go	(working copy)
@@ -6,14 +6,14 @@ 
 
 package main
 
-func f(x int, y ...)	// ok
+func f(x int, y ...int)	// ok
 
 func g(x int, y float) (...)	// ERROR "[.][.][.]"
 
-func h(x, y ...)		// ERROR "[.][.][.]"
+func h(x, y ...int)		// ERROR "[.][.][.]"
 
-func i(x int, y ..., z float)	// ERROR "[.][.][.]"
+func i(x int, y ...int, z float)	// ERROR "[.][.][.]"
 
-var x ...;		// ERROR "[.][.][.]|syntax|type"
+var x ...int;		// ERROR "[.][.][.]|syntax|type"
 
-type T ...;		// ERROR "[.][.][.]|syntax|type"
+type T ...int;		// ERROR "[.][.][.]|syntax|type"