]> granicus.if.org Git - clang/commitdiff
Allow variadic arguments without named ones for C++, e.g. "void(...);"
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Mon, 6 Oct 2008 00:07:55 +0000 (00:07 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Mon, 6 Oct 2008 00:07:55 +0000 (00:07 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57143 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Parse/ParseDecl.cpp
test/Parser/cxx-variadic-func.cpp [new file with mode: 0644]

index c22d9e871b0cbee7ad048f3769b98a4c775261d8..3017da4821333c0e24f51a621e67110ec4879d59 100644 (file)
@@ -1233,6 +1233,7 @@ void Parser::ParseParenDeclarator(Declarator &D) {
     // paren, because we haven't seen the identifier yet.
     isGrouping = true;
   } else if (Tok.is(tok::r_paren) ||           // 'int()' is a function.
+             (getLang().CPlusPlus && Tok.is(tok::ellipsis)) || // C++ int(...)
              isDeclarationSpecifier()) {       // 'int(int)' is a function.
     // This handles C99 6.7.5.3p11: in "typedef int X; void foo(X)", X is
     // considered to be a type, not a K&R identifier-list.
@@ -1326,7 +1327,7 @@ void Parser::ParseFunctionDeclarator(SourceLocation LParenLoc, Declarator &D) {
       IsVariadic = true;
       
       // Check to see if this is "void(...)" which is not allowed.
-      if (ParamInfo.empty()) {
+      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);
diff --git a/test/Parser/cxx-variadic-func.cpp b/test/Parser/cxx-variadic-func.cpp
new file mode 100644 (file)
index 0000000..0ef8684
--- /dev/null
@@ -0,0 +1,5 @@
+// RUN: clang -fsyntax-only  %s\r
+\r
+void f(...) {\r
+  int g(int(...));\r
+}\r