diff options
author | John McCall <rjmccall@apple.com> | 2009-12-09 03:35:25 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2009-12-09 03:35:25 +0000 |
commit | daa3d6bb502a356780ab112623ff64ff1f501e6f (patch) | |
tree | 400603ba67b58f53a11d78b3609fef68bf8bd021 /clang/lib/Sema/SemaDecl.cpp | |
parent | 31c7e88667174a4410e8eeb1f0322db7c1daa61e (diff) | |
download | bcm5719-llvm-daa3d6bb502a356780ab112623ff64ff1f501e6f.tar.gz bcm5719-llvm-daa3d6bb502a356780ab112623ff64ff1f501e6f.zip |
Rename Sema::IsOverload to Sema::CheckOverload. Teach it to ignore unresolved
using value decls; we optimistically assume they won't turn into conflicts.
Teach it to tell the caller *why* the function doesn't overload with the returned
decl; this will be useful for using hiding.
llvm-svn: 90939
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 58 |
1 files changed, 34 insertions, 24 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 54e6f88fd83..392360f5aa8 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -3165,34 +3165,44 @@ void Sema::CheckFunctionDeclaration(FunctionDecl *NewFD, // there's no more work to do here; we'll just add the new // function to the scope. - if (!getLangOptions().CPlusPlus && - AllowOverloadingOfFunction(Previous, Context)) { - OverloadableAttrRequired = true; - - // Functions marked "overloadable" must have a prototype (that - // we can't get through declaration merging). - if (!NewFD->getType()->getAs<FunctionProtoType>()) { - Diag(NewFD->getLocation(), diag::err_attribute_overloadable_no_prototype) - << NewFD; - Redeclaration = true; + NamedDecl *OldDecl = 0; + if (!AllowOverloadingOfFunction(Previous, Context)) { + Redeclaration = true; + OldDecl = Previous.getFoundDecl(); + } else { + if (!getLangOptions().CPlusPlus) { + OverloadableAttrRequired = true; + + // Functions marked "overloadable" must have a prototype (that + // we can't get through declaration merging). + if (!NewFD->getType()->getAs<FunctionProtoType>()) { + Diag(NewFD->getLocation(), + diag::err_attribute_overloadable_no_prototype) + << NewFD; + Redeclaration = true; - // Turn this into a variadic function with no parameters. - QualType R = Context.getFunctionType( - NewFD->getType()->getAs<FunctionType>()->getResultType(), - 0, 0, true, 0); - NewFD->setType(R); - return NewFD->setInvalidDecl(); + // Turn this into a variadic function with no parameters. + QualType R = Context.getFunctionType( + NewFD->getType()->getAs<FunctionType>()->getResultType(), + 0, 0, true, 0); + NewFD->setType(R); + return NewFD->setInvalidDecl(); + } } - } - NamedDecl *OldDecl = 0; - if (!Previous.empty()) { - if (!AllowOverloadingOfFunction(Previous, Context)) { + switch (CheckOverload(NewFD, Previous, OldDecl)) { + case Ovl_Match: + // FIXME: hide or conflict with using shadow decls as appropriate + Redeclaration = !isa<UsingShadowDecl>(OldDecl); + break; + + case Ovl_NonFunction: Redeclaration = true; - OldDecl = Previous.getFoundDecl(); - } else if (!IsOverload(NewFD, Previous, OldDecl)) { - if (!isUsingDecl(OldDecl)) - Redeclaration = true; + break; + + case Ovl_Overload: + Redeclaration = false; + break; } } |