Index: lib/Sema/SemaLookup.cpp =================================================================== --- lib/Sema/SemaLookup.cpp +++ lib/Sema/SemaLookup.cpp @@ -1535,9 +1535,13 @@ return true; } + DeclContext *DC = D->getLexicalDeclContext(); + // If this declaration is a tag in a function decl it should be visible. + if (isa(D) && DC && DC->isFunctionOrMethod()) + return true; + // If this declaration is not at namespace scope nor module-private, // then it is visible if its lexical parent has a visible definition. - DeclContext *DC = D->getLexicalDeclContext(); if (!D->isModulePrivate() && DC && !DC->isFileContext() && !isa(DC)) { // For a parameter, check whether our current template declaration's Index: test/Modules/Inputs/PR28794/LibAHeader.h =================================================================== --- /dev/null +++ test/Modules/Inputs/PR28794/LibAHeader.h @@ -0,0 +1,12 @@ +#ifndef LIB_A_HEADER +#define LIB_A_HEADER + +typedef __SIZE_TYPE__ size_t; + +template +class BumpPtrAllocatorImpl; + +template +void * operator new(size_t, BumpPtrAllocatorImpl &); + +#endif // LIB_A_HEADER Index: test/Modules/Inputs/PR28794/Subdir/Empty.h =================================================================== --- /dev/null +++ test/Modules/Inputs/PR28794/Subdir/Empty.h @@ -0,0 +1 @@ + Index: test/Modules/Inputs/PR28794/Subdir/LibBHeader.h =================================================================== --- /dev/null +++ test/Modules/Inputs/PR28794/Subdir/LibBHeader.h @@ -0,0 +1,12 @@ +#ifndef LIB_B_HEADER +#define LIB_B_HEADER + +#include "LibAHeader.h" + +template +void *operator new(size_t, BumpPtrAllocatorImpl &) { + struct S {}; + return (void*)0xdead; +} + +#endif // LIB_B_HEADER Index: test/Modules/Inputs/PR28794/module.modulemap =================================================================== --- /dev/null +++ test/Modules/Inputs/PR28794/module.modulemap @@ -0,0 +1,3 @@ +module M { + umbrella "Subdir" module * {export *} +} Index: test/Modules/pr28794.cpp =================================================================== --- /dev/null +++ test/Modules/pr28794.cpp @@ -0,0 +1,17 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -std=c++11 -I%S/Inputs/PR28794 -verify %s +// RUN: %clang_cc1 -std=c++11 -fmodules -fmodule-map-file=%S/Inputs/PR28794/module.modulemap -fmodules-cache-path=%t -I%S/Inputs/PR28794/ -verify %s + +#include "Subdir/Empty.h" +#include "LibAHeader.h" + +BumpPtrAllocatorImpl<> &getPreprocessorAllocator(); +class B { + struct ModuleMacroInfo { + ModuleMacroInfo *getModuleInfo() { + return new (getPreprocessorAllocator()) ModuleMacroInfo(); + } + }; +}; + +// expected-no-diagnostics