[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gcc-patches
Subject:    [gccgo] Expect a type after an erroneous ellipsis
From:       Ian Lance Taylor <iant () google ! com>
Date:       2010-08-31 21:15:02
Message-ID: mcrwrr6cwmh.fsf () google ! com
[Download RAW message or body]

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


["foo.patch" (text/x-diff)]

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"


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic