Implement DR577

DR18 previously forebode typedefs to be used as parameter types if they
were of type 'void'.  DR577 allows 'void' to be used as a function
parameter type regardless from where it came.

llvm-svn: 201631
This commit is contained in:
David Majnemer 2014-02-19 03:00:56 +00:00
parent f903a44728
commit f703b588b8
7 changed files with 3 additions and 27 deletions

View File

@ -2510,8 +2510,6 @@ def err_ident_list_in_fn_declaration : Error<
"a parameter list without types is only allowed in a function definition">;
def ext_param_not_declared : Extension<
"parameter %0 was not declared, defaulting to type 'int'">;
def err_param_typedef_of_void : Error<
"empty parameter list defined with a %select{typedef|type alias}0 of 'void' not allowed%select{ in C++|}0">;
def err_param_default_argument : Error<
"C does not support default arguments">;
def err_param_default_argument_redefinition : Error<

View File

@ -1521,7 +1521,6 @@ public:
MultiTemplateParamsArg TemplateParamLists,
bool &AddToScope);
bool AddOverriddenMethods(CXXRecordDecl *DC, CXXMethodDecl *MD);
void checkVoidParamDecl(ParmVarDecl *Param);
bool CheckConstexprFunctionDecl(const FunctionDecl *FD);
bool CheckConstexprFunctionBody(const FunctionDecl *FD, Stmt *Body);

View File

@ -6357,22 +6357,6 @@ static FunctionDecl* CreateNewFunctionDecl(Sema &SemaRef, Declarator &D,
}
}
void Sema::checkVoidParamDecl(ParmVarDecl *Param) {
// In C++, the empty parameter-type-list must be spelled "void"; a
// typedef of void is not permitted.
if (getLangOpts().CPlusPlus &&
Param->getType().getUnqualifiedType() != Context.VoidTy) {
bool IsTypeAlias = false;
if (const TypedefType *TT = Param->getType()->getAs<TypedefType>())
IsTypeAlias = isa<TypeAliasDecl>(TT->getDecl());
else if (const TemplateSpecializationType *TST =
Param->getType()->getAs<TemplateSpecializationType>())
IsTypeAlias = TST->isTypeAlias();
Diag(Param->getLocation(), diag::err_param_typedef_of_void)
<< IsTypeAlias;
}
}
enum OpenCLParamType {
ValidKernelParam,
PtrPtrKernelParam,
@ -6915,7 +6899,6 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC,
FTI.ArgInfo[0].Param &&
cast<ParmVarDecl>(FTI.ArgInfo[0].Param)->getType()->isVoidType()) {
// Empty arg list, don't push any params.
checkVoidParamDecl(cast<ParmVarDecl>(FTI.ArgInfo[0].Param));
} else if (FTI.NumArgs > 0 && FTI.ArgInfo[0].Param != 0) {
for (unsigned i = 0, e = FTI.NumArgs; i != e; ++i) {
ParmVarDecl *Param = cast<ParmVarDecl>(FTI.ArgInfo[i].Param);

View File

@ -901,7 +901,6 @@ void Sema::ActOnStartOfLambdaDefinition(LambdaIntroducer &Intro,
if (FTI.NumArgs == 1 && !FTI.isVariadic && FTI.ArgInfo[0].Ident == 0 &&
cast<ParmVarDecl>(FTI.ArgInfo[0].Param)->getType()->isVoidType()) {
// Empty arg list, don't push any params.
checkVoidParamDecl(cast<ParmVarDecl>(FTI.ArgInfo[0].Param));
} else {
Params.reserve(FTI.NumArgs);
for (unsigned i = 0, e = FTI.NumArgs; i != e; ++i)

View File

@ -154,5 +154,5 @@ namespace Access {
namespace VoidArg {
using V = void;
V f(int); // ok
V g(V); // expected-error {{empty parameter list defined with a type alias of 'void' not allowed}}
V g(V); // ok (DR577)
}

View File

@ -194,10 +194,7 @@ namespace dr17 { // dr17: yes
};
}
namespace dr18 { // dr18: yes
typedef void Void;
void f(Void); // expected-error {{empty parameter list defined with a typedef of 'void'}}
}
// dr18: sup 577
namespace dr19 { // dr19: yes
struct A {

View File

@ -136,7 +136,7 @@ namespace Access {
namespace VoidArg {
template<typename Z> using V = void;
V<int> f(int); // ok
V<char> g(V<double>); // expected-error {{empty parameter list defined with a type alias of 'void' not allowed}}
V<char> g(V<double>); // ok (DR577)
}
namespace Curried {