diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-02-18 06:34:51 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-02-18 06:34:51 +0000 |
commit | c6666f8e9bbb7f31bf2e52f97137e738c4ca01d0 (patch) | |
tree | df0b4fbf0b7db30dc79a52ce27432d6e34af80d4 /lib/Sema/SemaDecl.cpp | |
parent | f4b136fb40aeedeaaa6ce7cdff22f375eb76c47b (diff) |
Don't allow calls to functions marked "unavailable". There's more work
to do in this area, since there are other places that reference
FunctionDecls.
Don't allow "overloadable" functions (in C) to be declared without a
prototype.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64897 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDecl.cpp')
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 55e2a92476..0543b0adc6 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -1763,11 +1763,27 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC, OverloadedFunctionDecl::function_iterator MatchedDecl; if (!getLangOptions().CPlusPlus && - AllowOverloadingOfFunction(PrevDecl, Context)) + AllowOverloadingOfFunction(PrevDecl, Context)) { OverloadableAttrRequired = true; - if (!AllowOverloadingOfFunction(PrevDecl, Context) || - !IsOverload(NewFD, PrevDecl, MatchedDecl)) { + // Functions marked "overloadable" must have a prototype (that + // we can't get through declaration merging). + if (!R->getAsFunctionTypeProto()) { + Diag(NewFD->getLocation(), diag::err_attribute_overloadable_no_prototype) + << NewFD; + InvalidDecl = true; + Redeclaration = true; + + // Turn this into a variadic function with no parameters. + R = Context.getFunctionType(R->getAsFunctionType()->getResultType(), + 0, 0, true, 0); + NewFD->setType(R); + } + } + + if (PrevDecl && + (!AllowOverloadingOfFunction(PrevDecl, Context) || + !IsOverload(NewFD, PrevDecl, MatchedDecl))) { Redeclaration = true; Decl *OldDecl = PrevDecl; |