aboutsummaryrefslogtreecommitdiff
path: root/lib/Parse/ParseDecl.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-02-18 07:07:28 +0000
committerDouglas Gregor <dgregor@apple.com>2009-02-18 07:07:28 +0000
commit965acbb321e94e36aa5365126eee46b97745fdbb (patch)
treeb90c16f0aedbfca9146e07251c896cd22d9fd9c6 /lib/Parse/ParseDecl.cpp
parentc6c16af963eddc3e9b75b5d2614d069e1162fe27 (diff)
Allow "overloadable" functions in C to be declared as variadic without
any named parameters, e.g., this is accepted in C: void f(...) __attribute__((overloadable)); although this would be rejected: void f(...); To do this, moved the checking of the "ellipsis without any named arguments" condition from the parser into Sema (where it belongs anyway). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64902 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Parse/ParseDecl.cpp')
-rw-r--r--lib/Parse/ParseDecl.cpp15
1 files changed, 5 insertions, 10 deletions
diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp
index 953b552562..9974aea005 100644
--- a/lib/Parse/ParseDecl.cpp
+++ b/lib/Parse/ParseDecl.cpp
@@ -2036,6 +2036,7 @@ void Parser::ParseFunctionDeclarator(SourceLocation LParenLoc, Declarator &D,
// int() -> no prototype, no '...'.
D.AddTypeInfo(DeclaratorChunk::getFunction(/*prototype*/getLang().CPlusPlus,
/*variadic*/ false,
+ SourceLocation(),
/*arglist*/ 0, 0,
DS.getTypeQualifiers(),
LParenLoc, D),
@@ -2069,19 +2070,11 @@ void Parser::ParseFunctionDeclarator(SourceLocation LParenLoc, Declarator &D,
ParseScope PrototypeScope(this, Scope::FunctionPrototypeScope|Scope::DeclScope);
bool IsVariadic = false;
+ SourceLocation EllipsisLoc;
while (1) {
if (Tok.is(tok::ellipsis)) {
IsVariadic = true;
-
- // Check to see if this is "void(...)" which is not allowed.
- if (!getLang().CPlusPlus && ParamInfo.empty()) {
- // Otherwise, parse parameter type list. If it starts with an
- // ellipsis, diagnose the malformed function.
- Diag(Tok, diag::err_ellipsis_first_arg);
- IsVariadic = false; // Treat this like 'void()'.
- }
-
- ConsumeToken(); // Consume the ellipsis.
+ EllipsisLoc = ConsumeToken(); // Consume the ellipsis.
break;
}
@@ -2201,6 +2194,7 @@ void Parser::ParseFunctionDeclarator(SourceLocation LParenLoc, Declarator &D,
// Remember that we parsed a function type, and remember the attributes.
D.AddTypeInfo(DeclaratorChunk::getFunction(/*proto*/true, IsVariadic,
+ EllipsisLoc,
&ParamInfo[0], ParamInfo.size(),
DS.getTypeQualifiers(),
LParenLoc, D),
@@ -2273,6 +2267,7 @@ void Parser::ParseFunctionDeclaratorIdentifierList(SourceLocation LParenLoc,
// function type is always a K&R style function type, which is not varargs and
// has no prototype.
D.AddTypeInfo(DeclaratorChunk::getFunction(/*proto*/false, /*varargs*/false,
+ SourceLocation(),
&ParamInfo[0], ParamInfo.size(),
/*TypeQuals*/0, LParenLoc, D),
RLoc);