From: Benjamin Kramer Date: Fri, 27 Mar 2015 13:58:41 +0000 (+0000) Subject: [Sema] Implement DR777 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3e68ff59bbcc4b0c7011a619ca6dfeacc600689a;p=clang [Sema] Implement DR777 A parameter pack after a default argument is now valid. PR23029. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@233377 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp index bb7ba943c6..aa1bfac7e0 100644 --- a/lib/Sema/SemaDeclCXX.cpp +++ b/lib/Sema/SemaDeclCXX.cpp @@ -697,16 +697,16 @@ void Sema::CheckCXXDefaultArguments(FunctionDecl *FD) { break; } - // C++ [dcl.fct.default]p4: - // In a given function declaration, all parameters - // subsequent to a parameter with a default argument shall - // have default arguments supplied in this or previous - // declarations. A default argument shall not be redefined - // by a later declaration (not even to the same value). + // C++11 [dcl.fct.default]p4: + // In a given function declaration, each parameter subsequent to a parameter + // with a default argument shall have a default argument supplied in this or + // a previous declaration or shall be a function parameter pack. A default + // argument shall not be redefined by a later declaration (not even to the + // same value). unsigned LastMissingDefaultArg = 0; for (; p < NumParams; ++p) { ParmVarDecl *Param = FD->getParamDecl(p); - if (!Param->hasDefaultArg()) { + if (!Param->hasDefaultArg() && !Param->isParameterPack()) { if (Param->isInvalidDecl()) /* We already complained about this parameter. */; else if (Param->getIdentifier()) diff --git a/test/CXX/drs/dr7xx.cpp b/test/CXX/drs/dr7xx.cpp new file mode 100644 index 0000000000..a4ca74abe7 --- /dev/null +++ b/test/CXX/drs/dr7xx.cpp @@ -0,0 +1,20 @@ +// RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors +// RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors +// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors +// RUN: %clang_cc1 -std=c++1z %s -verify -fexceptions -fcxx-exceptions -pedantic-errors + +namespace dr777 { // dr777: yes +#if __cplusplus >= 201103L +template +void f(int i = 0, T ...args) {} +void ff() { f(); } + +template +void g(int i = 0, T ...args, T ...args2) {} + +template +void h(int i = 0, T ...args, int j = 1) {} +#endif +} + +// expected-no-diagnostics diff --git a/www/cxx_dr_status.html b/www/cxx_dr_status.html index e70604f8cb..66c65107d2 100644 --- a/www/cxx_dr_status.html +++ b/www/cxx_dr_status.html @@ -4681,7 +4681,7 @@ and POD class 777 CD2 Default arguments and parameter packs - Unknown + Yes 778