<div dir="ltr">Thanks for checking, Nick! <div>+Roland, FYI (recent changes in clang break compilation of all of the glibc),</div><div>similar to <a href="https://llvm.org/bugs/show_bug.cgi?id=22830#c1">https://llvm.org/bugs/show_bug.cgi?id=22830#c1</a></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jan 4, 2016 at 3:21 PM, Nick Lewycky <span dir="ltr"><<a href="mailto:nicholas@mxc.ca" target="_blank">nicholas@mxc.ca</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 01/04/2016 01:40 PM, Kostya Serebryany wrote:<br>
</span><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">
<br>
<br>
On Thu, Dec 17, 2015 at 5:03 PM, Richard Smith <<a href="mailto:richard@metafoo.co.uk" target="_blank">richard@metafoo.co.uk</a><br></span><span class="">
<mailto:<a href="mailto:richard@metafoo.co.uk" target="_blank">richard@metafoo.co.uk</a>>> wrote:<br>
<br>
On Thu, Dec 17, 2015 at 3:59 PM, Nick Lewycky via cfe-commits<br></span><div><div class="h5">
<<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a> <mailto:<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>>> wrote:<br>
<br>
On 12/17/2015 10:47 AM, Kostya Serebryany wrote:<br>
<br>
I am now observing this error message when building glibc<br>
with clang<br>
(from trunk):<br>
../include/string.h:101:28: error: cannot apply asm label to<br>
function<br>
after its first use<br>
libc_hidden_builtin_proto (memcpy)<br>
(many more instances)<br>
<br>
<br>
Do you think this is a bug in glibc code, or the error<br>
message could be<br>
more relaxed?<br>
<br>
<br>
Could you email me a .i copy of a failing build? That will help<br>
me decide whether it's a bug in the error or in glibc.<br>
<br>
<br>
[sorry for delay,]<br>
here is the preprocessed source file from glibc:<br>
% clang ~/tmp/a.i 2>&1 | grep error:<br>
../include/sys/stat.h:16:28: error: cannot apply asm label to function<br>
after its first use<br>
../include/sys/stat.h:17:30: error: cannot apply asm label to function<br>
after its first use<br>
../include/sys/stat.h:18:28: error: cannot apply asm label to function<br>
after its first use<br>
../include/sys/stat.h:19:30: error: cannot apply asm label to function<br>
after its first use<br>
...<br>
<br>
<br>
Also PR22830 comment 1 seems relevant here.<br>
<br>
<br>
Probably, but since this is a very recent regression in clang I thought<br>
I should report it.<br>
</div></div></blockquote>
<br>
This looks like it's WAI:<br>
<br>
3783 extern int __fxstat (int __ver, int __fildes, struct stat *__stat_buf)<br>
3784 __attribute__ ((__nothrow__ )) ;<br>
...<br>
3827 extern __inline int<br>
3828 __attribute__ ((__nothrow__ )) fstat (int __fd, struct stat *__statbuf)<br>
3829 {<br>
3830 return __fxstat (1, __fd, __statbuf);<br>
3831 }<br>
...<br>
3910 extern __typeof (__fxstat) __fxstat __asm__ ("" "__GI___fxstat") __attribute__ ((visibility ("hidden")));<br>
<br>
This is exactly the situation where GCC and Clang will emit a different .o file.<br>
<br>
Nick<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">
On Fri, Dec 11, 2015 at 1:28 PM, Nick Lewycky via cfe-commits<br>
<<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a><br>
<mailto:<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>><br></span>
<mailto:<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a><div><div class="h5"><br>
<mailto:<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>>>> wrote:<br>
<br>
Author: nicholas<br>
Date: Fri Dec 11 15:28:55 2015<br>
New Revision: 255371<br>
<br>
URL:<br>
<a href="http://llvm.org/viewvc/llvm-project?rev=255371&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=255371&view=rev</a><br>
Log:<br>
Error on redeclaring with a conflicting asm label and<br>
on redeclaring<br>
with an asm label after the first ODR-use. Detects<br>
problems like the<br>
one in PR22830 where gcc and clang both compiled the<br>
file but with<br>
different behaviour.<br>
<br>
Added:<br>
cfe/trunk/test/Sema/asm-label.c<br>
Modified:<br>
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td<br>
cfe/trunk/lib/Sema/SemaDecl.cpp<br>
<br>
Modified:<br>
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td<br>
URL:<br>
<a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=255371&r1=255370&r2=255371&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=255371&r1=255370&r2=255371&view=diff</a><br>
<br>
==============================================================================<br>
---<br>
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)<br>
+++<br>
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Dec 11<br>
15:28:55 2015<br>
@@ -4259,6 +4259,9 @@ def err_tag_definition_of_typedef<br>
: Erro<br>
def err_conflicting_types : Error<"conflicting types<br>
for %0">;<br>
def err_different_pass_object_size_params : Error<<br>
"conflicting pass_object_size attributes on<br>
parameters">;<br>
+def err_late_asm_label_name : Error<<br>
+ "cannot apply asm label to<br>
%select{variable|function}0 after its<br>
first use">;<br>
+def err_different_asm_label : Error<"conflicting asm<br>
label">;<br>
def err_nested_redefinition : Error<"nested<br>
redefinition of %0">;<br>
def err_use_with_wrong_tag : Error<<br>
"use of %0 with tag type that does not match<br>
previous declaration">;<br>
<br>
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp<br>
URL:<br>
<a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=255371&r1=255370&r2=255371&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=255371&r1=255370&r2=255371&view=diff</a><br>
<br>
==============================================================================<br>
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)<br>
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Fri Dec 11 15:28:55<br>
2015<br>
@@ -2379,9 +2379,24 @@ void<br>
Sema::mergeDeclAttributes(NamedDecl<br>
if (!Old->hasAttrs() && !New->hasAttrs())<br>
return;<br>
<br>
- // attributes declared post-definition are currently<br>
ignored<br>
+ // Attributes declared post-definition are currently<br>
ignored.<br>
checkNewAttributesAfterDef(*this, New, Old);<br>
<br>
+ if (AsmLabelAttr *NewA = New->getAttr<AsmLabelAttr>()) {<br>
+ if (AsmLabelAttr *OldA =<br>
Old->getAttr<AsmLabelAttr>()) {<br>
+ if (OldA->getLabel() != NewA->getLabel()) {<br>
+ // This redeclaration changes __asm__ label.<br>
+ Diag(New->getLocation(),<br>
diag::err_different_asm_label);<br>
+ Diag(OldA->getLocation(),<br>
diag::note_previous_declaration);<br>
+ }<br>
+ } else if (Old->isUsed()) {<br>
+ // This redeclaration adds an __asm__ label to a<br>
declaration<br>
that has<br>
+ // already been ODR-used.<br>
+ Diag(New->getLocation(),<br>
diag::err_late_asm_label_name)<br>
+ << isa<FunctionDecl>(Old) <<<br>
New->getAttr<AsmLabelAttr>()->getRange();<br>
+ }<br>
+ }<br>
+<br>
if (!Old->hasAttrs())<br>
return;<br>
<br>
<br>
Added: cfe/trunk/test/Sema/asm-label.c<br>
URL:<br>
<a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/asm-label.c?rev=255371&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/asm-label.c?rev=255371&view=auto</a><br>
<br>
==============================================================================<br>
--- cfe/trunk/test/Sema/asm-label.c (added)<br>
+++ cfe/trunk/test/Sema/asm-label.c Fri Dec 11 15:28:55<br>
2015<br>
@@ -0,0 +1,30 @@<br>
+// RUN: %clang_cc1 -verify %s<br>
+<br>
+void f();<br>
+void f() __asm__("fish");<br>
+void g();<br>
+<br>
+void f() {<br>
+ g();<br>
+}<br>
+void g() __asm__("gold"); // expected-error{{cannot<br>
apply asm<br>
label to function after its first use}}<br>
+<br>
+void h() __asm__("hose"); // expected-note{{previous<br>
declaration<br>
is here}}<br>
+void h() __asm__("hair"); //<br>
expected-error{{conflicting asm label}}<br>
+<br>
+int x;<br>
+int x __asm__("xenon");<br>
+int y;<br>
+<br>
+int test() { return y; }<br>
+<br>
+int y __asm__("yacht"); // expected-error{{cannot<br>
apply asm label<br>
to variable after its first use}}<br>
+<br>
+int z __asm__("zebra"); // expected-note{{previous<br>
declaration is<br>
here}}<br>
+int z __asm__("zooms"); //<br>
expected-error{{conflicting asm label}}<br>
+<br>
+<br>
+// No diagnostics on the following.<br>
+void __real_readlink() __asm("readlink");<br>
+void readlink() __asm("__protected_readlink");<br>
+void readlink() { __real_readlink(); }<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a><br>
<mailto:<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>><br></div></div>
<mailto:<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a><span class=""><br>
<mailto:<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">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/mailman/listinfo/cfe-commits</a><br>
<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br></span>
<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a> <mailto:<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">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/mailman/listinfo/cfe-commits</a><br>
<br>
<br>
<br>
</blockquote>
<br>
</blockquote></div><br></div>