<div dir="ltr">Looks like this caused PR34811, which caused a link error on a Chromium bot:<div><div><div><a href="https://build.chromium.org/p/chromium.fyi/builders/CFI%20Linux%20ToT/builds/7081">https://build.chromium.org/p/chromium.fyi/builders/CFI%20Linux%20ToT/builds/7081</a><br></div></div></div><div><br></div><div>The link error might be caused by an unrelated LTO bug, but this bug does seem real. Please take a look.</div><div><br></div><div>Peter</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Sep 21, 2017 at 9:33 PM, Richard Smith via cfe-commits <span dir="ltr"><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: rsmith<br>
Date: Thu Sep 21 21:33:20 2017<br>
New Revision: 313957<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=313957&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project?rev=313957&view=rev</a><br>
Log:<br>
Closure types have no name (and can't have a typedef name for linkage<br>
purposes), so they never formally have linkage.<br>
<br>
Modified:<br>
cfe/trunk/lib/AST/Decl.cpp<br>
cfe/trunk/test/CXX/basic/<wbr>basic.link/p8.cpp<br>
<br>
Modified: cfe/trunk/lib/AST/Decl.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=313957&r1=313956&r2=313957&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/lib/AST/<wbr>Decl.cpp?rev=313957&r1=313956&<wbr>r2=313957&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/lib/AST/Decl.cpp (original)<br>
+++ cfe/trunk/lib/AST/Decl.cpp Thu Sep 21 21:33:20 2017<br>
@@ -1104,24 +1104,25 @@ LinkageInfo LinkageComputer::getLVForClo<br>
else<br>
Owner = cast<NamedDecl>(ContextDecl);<br>
<br>
- // FIXME: If there is no owner, the closure should have no linkage.<br>
if (!Owner)<br>
- return LinkageInfo::external();<br>
+ return LinkageInfo::none();<br>
<br>
// If the owner has a deduced type, we need to skip querying the linkage and<br>
// visibility of that type, because it might involve this closure type. The<br>
// only effect of this is that we might give a lambda VisibleNoLinkage rather<br>
// than NoLinkage when we don't strictly need to, which is benign.<br>
auto *VD = dyn_cast<VarDecl>(Owner);<br>
- LinkageInfo OwnerLinkage =<br>
+ LinkageInfo OwnerLV =<br>
VD && VD->getType()-><wbr>getContainedDeducedType()<br>
? computeLVForDecl(Owner, computation, /*IgnoreVarTypeLinkage*/true)<br>
: getLVForDecl(Owner, computation);<br>
<br>
- // FIXME: This is wrong. A lambda never formally has linkage; if this<br>
- // calculation determines a lambda has external linkage, it should be<br>
- // downgraded to VisibleNoLinkage.<br>
- return OwnerLinkage;<br>
+ // A lambda never formally has linkage. But if the owner is externally<br>
+ // visible, then the lambda is too. We apply the same rules to blocks.<br>
+ if (!isExternallyVisible(OwnerLV.<wbr>getLinkage()))<br>
+ return LinkageInfo::none();<br>
+ return LinkageInfo(VisibleNoLinkage, OwnerLV.getVisibility(),<br>
+ OwnerLV.isVisibilityExplicit()<wbr>);<br>
}<br>
<br>
LinkageInfo LinkageComputer::<wbr>getLVForLocalDecl(const NamedDecl *D,<br>
<br>
Modified: cfe/trunk/test/CXX/basic/<wbr>basic.link/p8.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/basic/basic.link/p8.cpp?rev=313957&r1=313956&r2=313957&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/test/CXX/<wbr>basic/basic.link/p8.cpp?rev=<wbr>313957&r1=313956&r2=313957&<wbr>view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/test/CXX/basic/<wbr>basic.link/p8.cpp (original)<br>
+++ cfe/trunk/test/CXX/basic/<wbr>basic.link/p8.cpp Thu Sep 21 21:33:20 2017<br>
@@ -14,7 +14,7 @@ typedef decltype(f()) NoLinkage3;<br>
inline auto g() { return [] {}; }<br>
typedef decltype(g()) VisibleNoLinkage1;<br>
inline auto y = [] {};<br>
-typedef decltype(x) VisibleNoLinkage2;<br>
+typedef decltype(y) VisibleNoLinkage2;<br>
inline auto h() { struct {} x; return x; }<br>
typedef decltype(h()) VisibleNoLinkage3;<br>
<br>
@@ -42,19 +42,12 @@ void use_no_linkage() {<br>
no_linkage3(); // expected-note {{used here}}<br>
}<br>
<br>
-// FIXME: This should emit an extension warning. It does not because we<br>
-// incorrectly give the lambda external linkage.<br>
-extern VisibleNoLinkage1 visible_no_linkage1();<br>
-<br>
-// FIXME: We should accept this as an extension. We don't because we<br>
-// incorrectly give the lambda no linkage instead of "VisibleNoLinkage".<br>
-extern VisibleNoLinkage2 visible_no_linkage2(); // expected-error {{used but not defined}}<br>
-<br>
-// This case is correctly accepted as an extension.<br>
+extern VisibleNoLinkage1 visible_no_linkage1(); // expected-warning {{ISO C++ requires a definition}}<br>
+extern VisibleNoLinkage2 visible_no_linkage2(); // expected-warning {{ISO C++ requires a definition}}<br>
extern VisibleNoLinkage3 visible_no_linkage3(); // expected-warning {{ISO C++ requires a definition}}<br>
<br>
void use_visible_no_linkage() {<br>
- visible_no_linkage1();<br>
+ visible_no_linkage1(); // expected-note {{used here}}<br>
visible_no_linkage2(); // expected-note {{used here}}<br>
visible_no_linkage3(); // expected-note {{used here}}<br>
}<br>
<br>
<br>
______________________________<wbr>_________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">-- <div>Peter</div></div></div>
</div>