From 4a449d09baa6d0eeb8db4fbd1d63ea8bfd1e9dda Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Fri, 16 May 2014 02:14:42 +0000 Subject: [PATCH] Push implicitly-declared allocation functions into the IdResolver. Otherwise, declaration merging in modules is unable to find them and we get bogus errors and even crashes. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@208944 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaExprCXX.cpp | 4 +--- test/Modules/Inputs/cxx-decls-imported.h | 2 ++ test/Modules/cxx-decls.cpp | 4 ++++ 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp index b344225ab8..bfb209a074 100644 --- a/lib/Sema/SemaExprCXX.cpp +++ b/lib/Sema/SemaExprCXX.cpp @@ -2109,10 +2109,8 @@ void Sema::DeclareGlobalAllocationFunction(DeclarationName Name, } Alloc->setParams(ArrayRef(ParamDecls, NumParams)); - // FIXME: Also add this declaration to the IdentifierResolver, but - // make sure it is at the end of the chain to coincide with the - // global scope. Context.getTranslationUnitDecl()->addDecl(Alloc); + IdResolver.tryAddTopLevelDecl(Alloc, Name); } FunctionDecl *Sema::FindUsualDeallocationFunction(SourceLocation StartLoc, diff --git a/test/Modules/Inputs/cxx-decls-imported.h b/test/Modules/Inputs/cxx-decls-imported.h index 959d3feaaf..5c7f6fc344 100644 --- a/test/Modules/Inputs/cxx-decls-imported.h +++ b/test/Modules/Inputs/cxx-decls-imported.h @@ -18,3 +18,5 @@ private: static_assert(!__is_trivial(HasNontrivialDefaultConstructor), ""); static_assert(!__has_trivial_constructor(HasNontrivialDefaultConstructor), ""); + +void *operator new[](__SIZE_TYPE__); diff --git a/test/Modules/cxx-decls.cpp b/test/Modules/cxx-decls.cpp index d37594afb5..49ba8340d3 100644 --- a/test/Modules/cxx-decls.cpp +++ b/test/Modules/cxx-decls.cpp @@ -3,6 +3,8 @@ // expected-no-diagnostics +void use_implicit_new() { operator new[](3); } + @import dummy; @import cxx_decls.imported; @@ -22,3 +24,5 @@ void test_friends(HasFriends s) { static_assert(!__is_trivial(HasNontrivialDefaultConstructor), ""); static_assert(!__has_trivial_constructor(HasNontrivialDefaultConstructor), ""); + +void use_implicit_new_again() { operator new[](3); } -- 2.40.0