On Mon, 19 Jul 2021 at 19:46, Marek Polacek <pola...@redhat.com> wrote:
>
> On Sat, Jul 17, 2021 at 02:50:28PM -0700, Jason Merrill wrote:
> > On 7/16/21 6:34 PM, Jakub Jelinek wrote:
> > > On Fri, Jul 16, 2021 at 05:36:13PM -0400, Marek Polacek via Gcc-patches 
> > > wrote:
> > > > When implementing DR 1512 in r11-467 I neglected to reject ordered
> > > > comparison of two null pointers, like nullptr < nullptr.  This patch
> > > > fixes that omission.
> > > >
> > > > Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk?
> > > >
> > > >   DR 1512
> > > >   PR c++/99701
> > > >
> > > > gcc/cp/ChangeLog:
> > > >
> > > >   * cp-gimplify.c (cp_fold): Remove {LE,LT,GE,GT_EXPR} from
> > > >   a switch.
> > > >   * typeck.c (cp_build_binary_op): Reject ordered comparison
> > > >   of two null pointers.
> > > >
> > > > gcc/testsuite/ChangeLog:
> > > >
> > > >   * g++.dg/cpp0x/nullptr11.C: Remove invalid tests.
> > > >   * g++.dg/cpp0x/nullptr46.C: Add dg-error.
> > > >   * g++.dg/expr/ptr-comp4.C: New test.
> > > >
> > > > libstdc++-v3/ChangeLog:
> > > >
> > > >   * testsuite/20_util/tuple/comparison_operators/overloaded.cc:
> > > >   Add dg-error.
> > >
> > > Maybe it would be useful to have also a g++.dg/cpp2a/ testcase with
> > > nullptr <=> nullptr etc. (nullptr <=> 0, etc. what you test
> > > in ptr-comp4.C after #include <compare>).
> >
> > Sounds good.
>
> Done.
>
> > > +++ 
> > > b/libstdc++-v3/testsuite/20_util/tuple/comparison_operators/overloaded.cc
> > > @@ -49,3 +49,5 @@ TwistedLogic operator<(const Compares&, const 
> > > Compares&) { return {false}; }
> > >  auto a = std::make_tuple(nullptr, Compares{}, 2, 'U');
> > >  auto b = a == a;
> > >  auto c = a < a;
> > > +
> > > +// { dg-error "ordered comparison" "" { target *-*-* } 0 }
> >
> > If we can't test for the specific problematic line, let's split this
> > testcase into separate well-formed and ill-formed tests.
>
> Done, I don't know if there's a trick to check an error that comes
> from tuple.

The only way is to hardcode a line number from the header, but then
that breaks every time we add or remove anything in <tuple>. I prefer
to match line 0 these days, to avoid having to keep adjusting it.

>Jon, are you OK with what I'm doing here?  Since

I might have gone with overloaded_neg.cc instead of overloaded2.cc. A
_neg suffix is documented as a convention for negative tests, but we
don't follow it consistently, so either is fine.


> overloaded.cc and overloaded2.cc are essentially the same I could
> make the substance of the test into a separate file but since it's
> just a test, I didn't bother.

Yeah, the duplication seems fine.

>
> Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk?

The libstdc++ bit is fine, thanks.

Reply via email to