Index: cfe/trunk/lib/Sema/SemaDeclCXX.cpp =================================================================== --- cfe/trunk/lib/Sema/SemaDeclCXX.cpp +++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp @@ -4804,6 +4804,9 @@ } } + if (!cast(Member)->isExternallyVisible()) + continue; + if (!getDLLAttr(Member)) { auto *NewAttr = cast(ClassAttr->clone(S.getASTContext())); Index: cfe/trunk/test/CodeGenCXX/dllexport.cpp =================================================================== --- cfe/trunk/test/CodeGenCXX/dllexport.cpp +++ cfe/trunk/test/CodeGenCXX/dllexport.cpp @@ -691,6 +691,15 @@ USEMEMFUNC(ExplicitInstantiationDeclExportedTemplate, f); // M32-DAG: {{declare|define available_externally}} x86_thiscallcc void @"\01?f@?$ExplicitInstantiationDeclExportedTemplate@H@@QAEXXZ" +namespace { struct InternalLinkageType {}; } +struct __declspec(dllexport) PR23308 { + void f(InternalLinkageType*); +}; +void PR23308::f(InternalLinkageType*) {} +long use(PR23308* p) { p->f(nullptr); } +// M32-DAG: define internal x86_thiscallcc void @"\01?f@PR23308@@QAEXPAUInternalLinkageType@?A@@@Z" + + //===----------------------------------------------------------------------===// // Classes with template base classes Index: cfe/trunk/test/SemaCXX/dllexport.cpp =================================================================== --- cfe/trunk/test/SemaCXX/dllexport.cpp +++ cfe/trunk/test/SemaCXX/dllexport.cpp @@ -393,6 +393,12 @@ template struct __declspec(dllexport) ExplicitInstantiationDeclExportedTemplate {}; // expected-note{{attribute is here}} extern template struct ExplicitInstantiationDeclExportedTemplate; // expected-warning{{explicit instantiation declaration should not be 'dllexport'}} +namespace { struct InternalLinkageType {}; } +struct __declspec(dllexport) PR23308 { + void f(InternalLinkageType*); +}; +void PR23308::f(InternalLinkageType*) {} // No error; we don't try to export f because it has internal linkage. + //===----------------------------------------------------------------------===// // Classes with template base classes //===----------------------------------------------------------------------===//