diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2014-02-04 01:14:30 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2014-02-04 01:14:30 +0000 |
commit | bdd146435ff77f63c83823eeec4d763c6fb9a2d8 (patch) | |
tree | d61a74713f68cd0623c1ea8e690bc79f74c0e800 /clang/lib/Sema/SemaDecl.cpp | |
parent | 7437589fa186d1f0e58d7528bf9b7351fae5ffdc (diff) | |
download | bcm5719-llvm-bdd146435ff77f63c83823eeec4d763c6fb9a2d8.tar.gz bcm5719-llvm-bdd146435ff77f63c83823eeec4d763c6fb9a2d8.zip |
Add implicit declarations of allocation functions when looking them up for
redeclaration, not just when looking them up for a use -- we need the implicit
declaration to appropriately check various properties of them (notably, whether
they're deleted).
llvm-svn: 200729
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index d102cdf55dd..995898aea48 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -2304,11 +2304,14 @@ bool Sema::MergeFunctionDecl(FunctionDecl *New, Decl *OldD, Scope *S, // Determine whether the previous declaration was a definition, // implicit declaration, or a declaration. diag::kind PrevDiag; + SourceLocation OldLocation = Old->getLocation(); if (Old->isThisDeclarationADefinition()) PrevDiag = diag::note_previous_definition; - else if (Old->isImplicit()) + else if (Old->isImplicit()) { PrevDiag = diag::note_previous_implicit_declaration; - else + if (OldLocation.isInvalid()) + OldLocation = New->getLocation(); + } else PrevDiag = diag::note_previous_declaration; // Don't complain about this if we're in GNU89 mode and the old function @@ -2322,10 +2325,10 @@ bool Sema::MergeFunctionDecl(FunctionDecl *New, Decl *OldD, Scope *S, !canRedefineFunction(Old, getLangOpts())) { if (getLangOpts().MicrosoftExt) { Diag(New->getLocation(), diag::warn_static_non_static) << New; - Diag(Old->getLocation(), PrevDiag); + Diag(OldLocation, PrevDiag); } else { Diag(New->getLocation(), diag::err_static_non_static) << New; - Diag(Old->getLocation(), PrevDiag); + Diag(OldLocation, PrevDiag); return true; } } @@ -2391,7 +2394,7 @@ bool Sema::MergeFunctionDecl(FunctionDecl *New, Decl *OldD, Scope *S, Diag(New->getLocation(), diag::err_regparm_mismatch) << NewType->getRegParmType() << OldType->getRegParmType(); - Diag(Old->getLocation(), diag::note_previous_declaration); + Diag(OldLocation, diag::note_previous_declaration); return true; } @@ -2403,7 +2406,7 @@ bool Sema::MergeFunctionDecl(FunctionDecl *New, Decl *OldD, Scope *S, if (OldTypeInfo.getProducesResult() != NewTypeInfo.getProducesResult()) { if (NewTypeInfo.getProducesResult()) { Diag(New->getLocation(), diag::err_returns_retained_mismatch); - Diag(Old->getLocation(), diag::note_previous_declaration); + Diag(OldLocation, diag::note_previous_declaration); return true; } @@ -2468,7 +2471,7 @@ bool Sema::MergeFunctionDecl(FunctionDecl *New, Decl *OldD, Scope *S, diag::err_member_def_does_not_match_ret_type) << New; else Diag(New->getLocation(), diag::err_ovl_diff_return_type); - Diag(Old->getLocation(), PrevDiag) << Old << Old->getType(); + Diag(OldLocation, PrevDiag) << Old << Old->getType(); return true; } else @@ -2514,7 +2517,7 @@ bool Sema::MergeFunctionDecl(FunctionDecl *New, Decl *OldD, Scope *S, // is a static member function declaration. if (OldMethod->isStatic() != NewMethod->isStatic()) { Diag(New->getLocation(), diag::err_ovl_static_nonstatic_member); - Diag(Old->getLocation(), PrevDiag) << Old << Old->getType(); + Diag(OldLocation, PrevDiag) << Old << Old->getType(); return true; } @@ -2538,7 +2541,7 @@ bool Sema::MergeFunctionDecl(FunctionDecl *New, Decl *OldD, Scope *S, Diag(New->getLocation(), diag::err_member_redeclared_in_instantiation) << New << New->getType(); } - Diag(Old->getLocation(), PrevDiag) << Old << Old->getType(); + Diag(OldLocation, PrevDiag) << Old << Old->getType(); // Complain if this is an explicit declaration of a special // member that was initially declared implicitly. @@ -2611,10 +2614,10 @@ bool Sema::MergeFunctionDecl(FunctionDecl *New, Decl *OldD, Scope *S, // Check cautiously as the friend object kind isn't yet complete. if (New->getFriendObjectKind() != Decl::FOK_None) { Diag(New->getLocation(), diag::ext_retained_language_linkage) << New; - Diag(Old->getLocation(), PrevDiag); + Diag(OldLocation, PrevDiag); } else { Diag(New->getLocation(), diag::err_different_language_linkage) << New; - Diag(Old->getLocation(), PrevDiag); + Diag(OldLocation, PrevDiag); return true; } } @@ -2751,7 +2754,7 @@ bool Sema::MergeFunctionDecl(FunctionDecl *New, Decl *OldD, Scope *S, // or 'printf', just warn about the incompatible redeclaration. if (Context.BuiltinInfo.isPredefinedLibFunction(BuiltinID)) { Diag(New->getLocation(), diag::warn_redecl_library_builtin) << New; - Diag(Old->getLocation(), diag::note_previous_builtin_declaration) + Diag(OldLocation, diag::note_previous_builtin_declaration) << Old << Old->getType(); // If this is a global redeclaration, just forget hereafter @@ -2772,7 +2775,7 @@ bool Sema::MergeFunctionDecl(FunctionDecl *New, Decl *OldD, Scope *S, } Diag(New->getLocation(), diag::err_conflicting_types) << New->getDeclName(); - Diag(Old->getLocation(), PrevDiag) << Old << Old->getType(); + Diag(OldLocation, PrevDiag) << Old << Old->getType(); return true; } |