<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, May 11, 2015 at 12:27 PM, Charlie Turner <span dir="ltr"><<a href="mailto:charlie.turner@arm.com" target="_blank">charlie.turner@arm.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">In <a href="http://reviews.llvm.org/D9157#159383" target="_blank">http://reviews.llvm.org/D9157#159383</a>, @rsmith wrote:<br>
<br>
> What is the motivation for this? Every version of libstdc++ I can find uses the keyword `bool` and not a typedef.<br>
<br>
<br>
</span>Sorry for the late reply Richard... I've also lost the previous thread I had with. I originally suggested the motivation was for cases like,<br>
<span class=""><br>
  typedef bool BOOL;<br>
<br>
  class Foo {<br>
      static const BOOL __is_signed;<br>
</span>    };<br>
<br>
  #include <map><br>
<br>
  int main() {}<br>
<br>
But as you pointed out, this is ill-formed. I found a smaller example, which I'm confident is well-formed yet rejected by Clang,<br>
<br>
  typedef bool Bool;<br>
  #define bool Bool<br>
<br>
  #include <algorithm><br>
<br>
  int main(void) {}<br>
<br>
I see the following errors<br>
<br>
  In file included from blentest.c:4:<br>
  In file included from /usr/lib/gcc/x86_64-linux-gnu/4.9/../../../../include/c++/4.9/algorithm:61:<br>
  In file included from /usr/lib/gcc/x86_64-linux-gnu/4.9/../../../../include/c++/4.9/bits/stl_algobase.h:63:<br>
  /usr/lib/gcc/x86_64-linux-gnu/4.9/../../../../include/c++/4.9/ext/numeric_traits.h:63:25: error: expected member name or ';' after declaration specifiers<br>
        static const bool __is_signed = __glibcxx_signed(_Value);<br>
        ~~~~~~~~~~~~~~~~~ ^<br>
  /usr/lib/gcc/x86_64-linux-gnu/4.9/../../../../include/c++/4.9/ext/numeric_traits.h:74:50: error: expected unqualified-id<br>
      const bool __numeric_traits_integer<_Value>::__is_signed;<br>
                                                   ^<br>
  /usr/lib/gcc/x86_64-linux-gnu/4.9/../../../../include/c++/4.9/ext/numeric_traits.h:106:25: error: expected member name or ';' after declaration specifiers<br>
<span class="">        static const bool __is_signed = true;<br>
</span>        ~~~~~~~~~~~~~~~~~ ^<br>
  /usr/lib/gcc/x86_64-linux-gnu/4.9/../../../../include/c++/4.9/ext/numeric_traits.h:115:51: error: expected unqualified-id<br>
      const bool __numeric_traits_floating<_Value>::__is_signed;<br>
                                                    ^<br>
  In file included from blentest.c:4:<br>
  In file included from /usr/lib/gcc/x86_64-linux-gnu/4.9/../../../../include/c++/4.9/algorithm:61:<br>
  /usr/lib/gcc/x86_64-linux-gnu/4.9/../../../../include/c++/4.9/bits/stl_algobase.h:941:49: error: expected unqualified-id<br>
           && !__gnu_cxx::__numeric_traits<_ValueType1>::__is_signed<br>
                                                         ^<br>
  /usr/lib/gcc/x86_64-linux-gnu/4.9/../../../../include/c++/4.9/bits/stl_algobase.h:946:45: error: non-type template argument of type 'Bool' (aka 'bool') is not an integral constant expression<br>
        return std::__lexicographical_compare<__simple>::__lc(__first1, __last1,<br>
                                              ^~~~~~~~<br>
  6 errors generated.<br>
<br>
The only restrictions I can see stated in the C++ standard (N4296, 2014-11-19) are in section 17.6.4.3.1, and they only cover that you're not allowed to `#define` or `#undef` names declared in a standard library header, or `override`, `final` and some other bits about attributes.</blockquote><div><br></div><div>It also says "names lexically identical to keywords", which covers 'bool'.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">`bool` is a fundamental type, so I think my example above should be accepted.<br>
<br>
I think reopening PR9804 for this was incorrect, it looks quite similar, but perhaps I should open a new PR for this issue. Do you agree?<br>
<br>
Thank you for your time. :)<br>
<span class=""><br>
<br>
REPOSITORY<br>
  rL LLVM<br>
<br>
<a href="http://reviews.llvm.org/D9157" target="_blank">http://reviews.llvm.org/D9157</a><br>
<br>
</span>EMAIL PREFERENCES<br>
  <a href="http://reviews.llvm.org/settings/panel/emailpreferences/" target="_blank">http://reviews.llvm.org/settings/panel/emailpreferences/</a><br>
<br>
<br>
</blockquote></div><br></div></div>