diff options
Diffstat (limited to 'lib/Sema')
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 3 | ||||
-rw-r--r-- | lib/Sema/SemaType.cpp | 16 |
2 files changed, 18 insertions, 1 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 0543b0adc6..92f167dcf2 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -2928,7 +2928,8 @@ NamedDecl *Sema::ImplicitlyDefineFunction(SourceLocation Loc, Error = Error; // Silence warning. assert(!Error && "Error setting up implicit decl!"); Declarator D(DS, Declarator::BlockContext); - D.AddTypeInfo(DeclaratorChunk::getFunction(false, false, 0, 0, 0, Loc, D), + D.AddTypeInfo(DeclaratorChunk::getFunction(false, false, SourceLocation(), + 0, 0, 0, Loc, D), SourceLocation()); D.SetIdentifier(&II, Loc); diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp index e6aafdab08..a385a13f4c 100644 --- a/lib/Sema/SemaType.cpp +++ b/lib/Sema/SemaType.cpp @@ -474,6 +474,22 @@ QualType Sema::GetTypeForDeclarator(Declarator &D, Scope *S, unsigned Skip) { // C++ 8.3.5p2: If the parameter-declaration-clause is empty, the // function takes no arguments. T = Context.getFunctionType(T, NULL, 0, FTI.isVariadic,FTI.TypeQuals); + } else if (FTI.isVariadic) { + // We allow a zero-parameter variadic function in C if the + // function is marked with the "overloadable" + // attribute. Scan for this attribute now. + bool Overloadable = false; + for (const AttributeList *Attrs = D.getAttributes(); + Attrs; Attrs = Attrs->getNext()) { + if (Attrs->getKind() == AttributeList::AT_overloadable) { + Overloadable = true; + break; + } + } + + if (!Overloadable) + Diag(FTI.getEllipsisLoc(), diag::err_ellipsis_first_arg); + T = Context.getFunctionType(T, NULL, 0, FTI.isVariadic, 0); } else { // Simple void foo(), where the incoming T is the result type. T = Context.getFunctionTypeNoProto(T); |