summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-09-22 21:41:40 +0000
committerDouglas Gregor <dgregor@apple.com>2009-09-22 21:41:40 +0000
commit9bfc2e50a78642e0db04c01584d77f75d8e5f425 (patch)
treea9683774436c66eb52f09d9f50c28401e8d45f78 /clang/lib
parent3003001a8678da194522a4035da889469f066c76 (diff)
downloadbcm5719-llvm-9bfc2e50a78642e0db04c01584d77f75d8e5f425.tar.gz
bcm5719-llvm-9bfc2e50a78642e0db04c01584d77f75d8e5f425.zip
In C++, a variadic function does not need an ellipsis prior to the comma. Parse it in both C and C++, but diagnose it as an error in C with a fix-it hint to add the comma.
llvm-svn: 82576
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Parse/ParseDecl.cpp17
1 files changed, 16 insertions, 1 deletions
diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index 4ca5b48e8b6..75ff82772a1 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -2448,6 +2448,7 @@ void Parser::ParseParenDeclarator(Declarator &D) {
/// parameter-type-list: [C99 6.7.5]
/// parameter-list
/// parameter-list ',' '...'
+/// [C++] parameter-list '...'
///
/// parameter-list: [C99 6.7.5]
/// parameter-declaration
@@ -2647,7 +2648,21 @@ void Parser::ParseFunctionDeclarator(SourceLocation LParenLoc, Declarator &D,
}
// If the next token is a comma, consume it and keep reading arguments.
- if (Tok.isNot(tok::comma)) break;
+ if (Tok.isNot(tok::comma)) {
+ if (Tok.is(tok::ellipsis)) {
+ IsVariadic = true;
+ EllipsisLoc = ConsumeToken(); // Consume the ellipsis.
+
+ if (!getLang().CPlusPlus) {
+ // We have ellipsis without a preceding ',', which is ill-formed
+ // in C. Complain and provide the fix.
+ Diag(EllipsisLoc, diag::err_missing_comma_before_ellipsis)
+ << CodeModificationHint::CreateInsertion(EllipsisLoc, ", ");
+ }
+ }
+
+ break;
+ }
// Consume the comma.
ConsumeToken();
OpenPOWER on IntegriCloud