Bug 487990 -  Fix format of variadic functions

Change-Id: I802d032f733247178db46c8fe43fdb9350555509
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java
index 1923926..240db77 100644
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java
@@ -2582,7 +2582,9 @@
 					}
 					if (addEllipsis) {
 						if (i > 0) {
-							scribe.printNextToken(options.fSeparatorToken, options.fSpaceBeforeSeparator);
+							if (peekNextToken() == options.fSeparatorToken) {
+								scribe.printNextToken(options.fSeparatorToken, options.fSpaceBeforeSeparator);
+							}
 							scribe.printTrailingComment();
 						}
 						scribe.alignFragment(alignment, i);
diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CodeFormatterTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CodeFormatterTest.java
index 47269ee..47ee70c 100644
--- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CodeFormatterTest.java
+++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CodeFormatterTest.java
@@ -4777,4 +4777,15 @@
 	public void testNoexcept_Bug562723() throws Exception {
 		assertFormatterResult();
 	}
+
+	//void foo(int...) {}
+	//int main() {}
+
+	//void foo(int ...) {
+	//}
+	//int main() {
+	//}
+	public void testVariadicFunction_Bug487990() throws Exception {
+		assertFormatterResult();
+	}
 }