[PATCH v1] libstdc++: Move test for __cpp_lib_not_fn to after #include.
Luc Grosheintz
luc.grosheintz@gmail.com
Wed Sep 24 11:53:08 GMT 2025
On 9/24/25 1:40 PM, Jonathan Wakely wrote:
> On Tue, 23 Sept 2025 at 12:54, Luc Grosheintz <luc.grosheintz@gmail.com> wrote:
>>
>>
>>
>> On 9/23/25 1:49 PM, Jonathan Wakely wrote:
>>> On Tue, 23 Sept 2025 at 12:11, Luc Grosheintz <luc.grosheintz@gmail.com> wrote:
>>>>
>>>> When running the tests without pre-compiled headers
>>>> (--disable-libstdcxx-pch), the test fails, because the feature
>>>> testing macro (FTM) isn't defined yet.
>>>>
>>>> This commit moves checking the FMT to after including the header
>>>> <functional>.
>>>
>>> This patch is certainly correct, but all tests that check feature test
>>> macros should use:
>>>
>>> // { dg-add-options no_pch }
>>>
>>> This means they don't depend on whether PCH is enabled or not.
>>>
>>
>> Would you like me to create version.cc instead?
>
> I was going to say no, but Tomasz has persuaded me it's worth having a
> separate version.cc test for it (I won't say convinced, as I'm not
> entirely convinced, but I'm persuaded to go with it).
>
>
>
>> Then the rest of
>> the file keeps "running" even on builds with PCH (which seems
>> desirable to me).
>
> I'm not sure what you mean here ... no_pch doesn't mean the test is
> disabled for PCH builds, it only means that '-include bits/stdc++.h'
> is removed from the implicit options used to compile the test, so that
> the PCH file is not included.
>
> The test is still tested, whether or not the build enables PCH.
>
> i.e. it only changes the options used to compile the test, it's not a
> target selector like { target c++20 } which controls whether the test
> is skipped or not.
I think what happened was that I had an aversion to change
whether substantial tests run with or without PCH (I think
one finds name collisions and the other missing includes); and
then my brain made up an excuse (I thought it was a selector,
later I realized you likely suggested it because it isn't).
>
>>
>>>>
>>>> libstdc++-v3/ChangeLog:
>>>>
>>>> * testsuite/20_util/function_objects/not_fn/nttp.cc: Move
>>>> test for feature testing macro after #include.
>>>>
>>>> Signed-off-by: Luc Grosheintz <luc.grosheintz@gmail.com>
>>>> ---
>>>> .../testsuite/20_util/function_objects/not_fn/nttp.cc | 6 +++---
>>>> 1 file changed, 3 insertions(+), 3 deletions(-)
>>>>
>>>> diff --git a/libstdc++-v3/testsuite/20_util/function_objects/not_fn/nttp.cc b/libstdc++-v3/testsuite/20_util/function_objects/not_fn/nttp.cc
>>>> index d35d828f14c..57d2c6ccf52 100644
>>>> --- a/libstdc++-v3/testsuite/20_util/function_objects/not_fn/nttp.cc
>>>> +++ b/libstdc++-v3/testsuite/20_util/function_objects/not_fn/nttp.cc
>>>> @@ -2,15 +2,15 @@
>>>>
>>>> // { dg-do run { target c++26 } }
>>>>
>>>> +#include <functional>
>>>> +#include <testsuite_hooks.h>
>>>> +
>>>> #ifndef __cpp_lib_not_fn
>>>> # error "Feature test macro for not_fn is missing in <functional>"
>>>> #elif __cpp_lib_not_fn < 202306L
>>>> # error "Feature test macro for not_fn has wrong value in <functional>"
>>>> #endif
>>>>
>>>> -#include <functional>
>>>> -#include <testsuite_hooks.h>
>>>> -
>>>> using std::not_fn;
>>>>
>>>> int func(int, char) { return 0; }
>>>> --
>>>> 2.50.1
>>>>
>>>
>>
>
More information about the Libstdc++
mailing list