]> granicus.if.org Git - clang/commitdiff
Push implicitly-declared allocation functions into the IdResolver. Otherwise,
authorRichard Smith <richard-llvm@metafoo.co.uk>
Fri, 16 May 2014 02:14:42 +0000 (02:14 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Fri, 16 May 2014 02:14:42 +0000 (02:14 +0000)
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
test/Modules/Inputs/cxx-decls-imported.h
test/Modules/cxx-decls.cpp

index b344225ab836b038b7135686f22504dae607ff11..bfb209a074f8b4ce3a1188bb7266e92c87a27793 100644 (file)
@@ -2109,10 +2109,8 @@ void Sema::DeclareGlobalAllocationFunction(DeclarationName Name,
   }
   Alloc->setParams(ArrayRef<ParmVarDecl*>(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,
index 959d3feaaf02ff61e3f24896108b30f2fd4f3dd5..5c7f6fc34427b185fc0c1b8b6b5f64e6bb2e0092 100644 (file)
@@ -18,3 +18,5 @@ private:
 
 static_assert(!__is_trivial(HasNontrivialDefaultConstructor), "");
 static_assert(!__has_trivial_constructor(HasNontrivialDefaultConstructor), "");
+
+void *operator new[](__SIZE_TYPE__);
index d37594afb5671227522e6459403e935ebb504be8..49ba8340d3e4106528b01e50e9113ce9125b9ca0 100644 (file)
@@ -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); }