<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Jul 7, 2015 at 8:18 AM, Reid Kleckner <span dir="ltr"><<a href="mailto:rnk@google.com" target="_blank">rnk@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">I think we should just fix the assert by erroring out from CodeGen when it detects that two Decls have the same mangled name. This might be tricky because we usually assume that decls have a unique mangled name.</div></blockquote><div><br></div><div>That is both reasonable and what we already attempt to do, but we don't do so particularly thoroughly or consistently. For instance:</div><div><br></div><div>  int _Z1fv;</div><div>  void f() {} // gives an error "definition with same mangled name as another definition"<br></div><div><br></div><div>but:</div><div><br></div><div>  void f() {}<br></div><div>  int _Z1fv; // no error, variable silently replaces function</div><div> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div>If people want to compile C++ transpiled to C, I don't see why clang should forbid that. The Itanium ABI restricts itself to valid C identifiers to support this exact use case.</div></div><div class=""><div class="h5"><div class="gmail_extra"><div class="gmail_quote"></div></div></div></div></blockquote><div><br></div><div>I agree. While it may be reasonable to warn on reserved identifiers outside system headers, we should still accept them when they don't conflict with some other meaning we've assigned to them. CodeGen needs to be able to deal with name conflicts, and should avoid crashing when they occur. And this problem is not limited to C++ name mangling; we get a conflict here too:</div><div><br></div><div>  int n = 1;</div><div>  int m __asm__("n") = 2;<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class=""><div class="h5"><div class="gmail_extra"><div class="gmail_quote">On Tue, Jul 7, 2015 at 7:44 AM, Andrey Bokhanko <span dir="ltr"><<a href="mailto:andreybokhanko@gmail.com" target="_blank">andreybokhanko@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Hmmm, maybe we should just check that identifiers don't start with<br>
_[A-Z] and print an error if they are?<br>
<br>
Richard [Smith], what do you think?<br>
<br>
Yours,<br>
Andrey<br>
<div><div><br>
<br>
On Tue, Jul 7, 2015 at 2:39 PM, Renato Golin <<a href="mailto:renato.golin@linaro.org" target="_blank">renato.golin@linaro.org</a>> wrote:<br>
> On 7 July 2015 at 12:20, Stephan Bergmann <<a href="mailto:sbergman@redhat.com" target="_blank">sbergman@redhat.com</a>> wrote:<br>
>> [<a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__lex.name&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=CnzuN65ENJ1H9py9XLiRvC_UQz6u3oG6GUNn7_wosSM&m=BV9n6nGZv4JUfbV7_ShwBz-4O1llMouPmSeuI8js704&s=v5LdUUW2huqCyBYqo4g3lJv1UaCiOGRK4iXE7CKiGwo&e=" rel="noreferrer" target="_blank">lex.name</a>]/3.1: "Each identifier that contains a double underscore __ or<br>
>> begins with an underscore followed by an<br>
>> uppercase letter is reserved to the implementation for any use."<br>
><br>
> Right, I always forget the _[A-Z] case. I guess how we deal with this<br>
> is up to interpretation.<br>
><br>
> cheers,<br>
> --renato<br>
> _______________________________________________<br>
> cfe-dev mailing list<br>
> <a href="mailto:cfe-dev@cs.uiuc.edu" target="_blank">cfe-dev@cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu" target="_blank">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div></div>