<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/76620>76620</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[libc++] Feature guards test too late
</td>
</tr>
<tr>
<th>Labels</th>
<td>
libc++
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
mordante
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
mordante
</td>
</tr>
</table>
<pre>
In this example:
```
In file included from weird.cc:1:
In file included from /home/luca/wasm-compilers/build/sysroot/include/c++/v1/thread:93:
In file included from /home/luca/wasm-compilers/build/sysroot/include/c++/v1/__thread/jthread.h:18:
/home/luca/wasm-compilers/build/sysroot/include/c++/v1/__thread/thread.h:55:34: error: unknown type name 'condition_variable'
55 | void notify_all_at_thread_exit(condition_variable*, mutex*);
| ^
```
The header `thread` validates the `_LIBCPP_HAS_NO_THREADS` macro _after_ including its granularized headers. We should validate the top-level header before starting to include unguarded headers. This should be done for all feature macros.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy8VMGOozgQ_ZriUmpk7ECSAwfSGTQtrXZHOy3tERlcBM8aO7JNurNfv4KQdB_6uitZUIDrvVemXskQ9MkSlZAfgPPReSVtJOAc8mMipzg4X97fJq1T1_LFYhx0QHqX49kQiArYEVgFBVvX8vhisdeGUNvOTIoU9t6N-Ebaq7TrQFTZI_PrrcDrwY0EvDZTJ4HXbzKMT50bz9qQD8DrdtJGAa_DNXjnIvB6RQBed8APy6ovGfA6Dp6kAlHtxf9J2zQrMa9_3aJ0mEvffZzaf0T3iS3PQVRiA6JC8t75OZjs39a9WYzXM6GVIyHwbees0lE721yk17I1BHx7k4mIeY6wfUbEi9MKrYu6vzbSmEbGlbahdx2B777CqYA_4zhFel_iPYjDAxlxQYb825eddLu-DoQDSUUeoWBrnQXDizRayUgB40Dzp-a3l8Pzjx_N9-pn8_sfzev3P79Vx5_z1lF23mEj-0i-WX-7tifUMeDJSzsZ6fU_pFaekOJfhGFwk1EPmoUluvOToQuZu6KWeucJQ5Q-zojR3bsKJ3uapFefUV9n-6y4LaFylrB3HqUx2JOMk6eb1pAmqhRqL_YyoTLbMrHPN0KIZCh3su0Ek23XbvfZjmVtzli_532ftSpnTCa65IyLjAuWFWKXizTLJeu6bSF2myJvNwQbRqPUJjXmMqbOnxIdwkTltig4S4xsyYR1LBjdPjptGQy-nJOe2ukUYMOMDjF8wEQdzTJQPqXlR6zXypbjCBgpRIzOoZGRksmbcojxHGZj8Bp4fdJxmNq0c-PsDXO5357O3v2ibvHBrHe2yCL53wAAAP__fG-H7g">