return PartialDiagnostic(DiagID, Context.getDiagAllocator());
}
+inline bool
+FTIHasSingleVoidParameter(const DeclaratorChunk::FunctionTypeInfo &FTI) {
+ return FTI.NumParams == 1 && !FTI.isVariadic && FTI.Params[0].Ident == 0 &&
+ FTI.Params[0].Param &&
+ cast<ParmVarDecl>(FTI.Params[0].Param)->getType()->isVoidType();
+}
+
+inline bool
+FTIHasNonVoidParameters(const DeclaratorChunk::FunctionTypeInfo &FTI) {
+ // Assume FTI is well-formed.
+ return FTI.NumParams && !FTIHasSingleVoidParameter(FTI);
+}
// This requires the variable to be non-dependent and the initializer
// to not be value dependent.
New->setType(NewQType);
New->setHasInheritedPrototype();
- // Synthesize a parameter for each argument type.
+ // Synthesize parameters with the same types.
SmallVector<ParmVarDecl*, 16> Params;
for (const auto &ParamType : OldProto->param_types()) {
ParmVarDecl *Param = ParmVarDecl::Create(Context, New, SourceLocation(),
// single void argument.
// We let through "const void" here because Sema::GetTypeForDeclarator
// already checks for that case.
- if (FTI.NumParams == 1 && !FTI.isVariadic && FTI.Params[0].Ident == 0 &&
- FTI.Params[0].Param &&
- cast<ParmVarDecl>(FTI.Params[0].Param)->getType()->isVoidType()) {
- // Empty arg list, don't push any params.
- } else if (FTI.NumParams > 0 && FTI.Params[0].Param != 0) {
+ if (FTIHasNonVoidParameters(FTI) && FTI.Params[0].Param) {
for (unsigned i = 0, e = FTI.NumParams; i != e; ++i) {
ParmVarDecl *Param = cast<ParmVarDecl>(FTI.Params[i].Param);
assert(Param->getDeclContext() != NewFD && "Was set before ?");
return false;
}
-static inline bool
-FTIHasSingleVoidArgument(DeclaratorChunk::FunctionTypeInfo &FTI) {
- return (FTI.NumParams == 1 && !FTI.isVariadic && FTI.Params[0].Ident == 0 &&
- FTI.Params[0].Param &&
- cast<ParmVarDecl>(FTI.Params[0].Param)->getType()->isVoidType());
-}
-
/// CheckDestructorDeclarator - Called by ActOnDeclarator to check
/// the well-formednes of the destructor declarator @p D with type @p
/// R. If there are any errors in the declarator, this routine will
}
// Make sure we don't have any parameters.
- if (FTI.NumParams > 0 && !FTIHasSingleVoidArgument(FTI)) {
+ if (FTIHasNonVoidParameters(FTI)) {
Diag(D.getIdentifierLoc(), diag::err_destructor_with_params);
// Delete the parameters.
ExplicitResultType = FTI.hasTrailingReturnType();
- if (FTI.NumParams == 1 && !FTI.isVariadic && FTI.Params[0].Ident == 0 &&
- cast<ParmVarDecl>(FTI.Params[0].Param)->getType()->isVoidType()) {
- // Empty arg list, don't push any params.
- } else {
+ if (FTIHasNonVoidParameters(FTI)) {
Params.reserve(FTI.NumParams);
for (unsigned i = 0, e = FTI.NumParams; i != e; ++i)
Params.push_back(cast<ParmVarDecl>(FTI.Params[i].Param));
<< getFunctionQualifiersAsString(T->castAs<FunctionProtoType>());
}
-/// Produce an approprioate diagnostic for an ambiguity between a function
+/// Produce an appropriate diagnostic for an ambiguity between a function
/// declarator and a C++ direct-initializer.
static void warnAboutAmbiguousFunction(Sema &S, Declarator &D,
DeclaratorChunk &DeclType, QualType RT) {