public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jason Merrill <jason@redhat.com>
To: Marek Polacek <polacek@redhat.com>
Cc: Christophe Lyon <christophe.lyon@linaro.org>,
	Tim Song <t.canens.cpp@gmail.com>,
		GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: C++ PATCH for c++/89024 - ICE with incomplete enum type
Date: Mon, 28 Jan 2019 17:01:00 -0000	[thread overview]
Message-ID: <CADzB+2kvH8U-MRAiqqY+EoT9SMJ=dSr3L+dZW73xBeh96fJBLQ@mail.gmail.com> (raw)
In-Reply-To: <20190128153959.GS26714@redhat.com>

On Mon, Jan 28, 2019 at 10:40 AM Marek Polacek <polacek@redhat.com> wrote:
> On Mon, Jan 28, 2019 at 10:37:01AM +0100, Christophe Lyon wrote:
> > On Sun, 27 Jan 2019 at 01:25, Jason Merrill <jason@redhat.com> wrote:
> > >
> > > On Fri, Jan 25, 2019 at 6:22 PM Marek Polacek <polacek@redhat.com> wrote:
> > > >
> > > > On Fri, Jan 25, 2019 at 12:14:07PM -0500, Jason Merrill wrote:
> > > > > On 1/25/19 12:09 PM, Marek Polacek wrote:
> > > > > > On Fri, Jan 25, 2019 at 10:55:55AM -0600, Tim Song wrote:
> > > > > > > On Thu, Jan 24, 2019 at 4:14 PM Jason Merrill <jason@redhat.com> wrote:
> > > > > > > >
> > > > > > > > On 1/24/19 2:16 PM, Marek Polacek wrote:
> > > > > > > > > This test ICEs since r159006 which added
> > > > > > > > >
> > > > > > > > >      type = ENUM_UNDERLYING_TYPE (type);
> > > > > > > > >
> > > > > > > > > to type_promotes_to.  In this test ENUM_UNDERLYING_TYPE is null because we
> > > > > > > > > haven't yet parsed '}' of the enum and the underlying type isn't fixed, and
> > > > > > > > > so checking TYPE_UNSIGNED crashed.
> > > > > > > > >
> > > > > > > > > I've added some checks to the test to see if the types seem to be OK; clang++
> > > > > > > > > agrees.
> > > > > > > > >
> > > > > > > > > Bootstrapped/regtested on x86_64-linux, ok for trunk/8/7?
> > > > > > > > >
> > > > > > > > > 2019-01-24  Marek Polacek  <polacek@redhat.com>
> > > > > > > > >
> > > > > > > > >        PR c++/89024 - ICE with incomplete enum type.
> > > > > > > > >        * cvt.c (type_promotes_to): Check if prom is non-null.
> > > > > > > >
> > > > > > > > 9.6/6: An enumeration whose underlying type is not fixed is an
> > > > > > > > incomplete type from its point of declaration to immediately after the
> > > > > > > > closing } of its enum-specifier, at which point it becomes a complete type.
> > > > > > > >
> > > > > > > > So the conversion is ill-formed.
> > > > > > > >
> > > > > > > > Jason
> > > > > > >
> > > > > > > But the conversion in the example (in
> > > > > > > decltype(__test_aux<_To1>(declval<_From1>())))
> > > > > > > is in a SFINAE context, so shouldn't it gracefully fall back to the
> > > > > > > `(...)` overload?
> > > > > >
> > > > > > I think so, and clang++ and icc also compile the testcase fine (and we used to
> > > > > > too, before r159006).
> > > > >
> > > > > Absolutely, the conversion being ill-formed means substitution fails, and we
> > > > > reject that candidate.  I meant that we shouldn't get as far as
> > > > > type_promotes_to for an incomplete type.
> > > >
> > > > Makes sense.  So here's another attempt:
> > > >
> > > > Bootstrapped/regtested on x86_64-linux, ok for trunk?
> > > >
> > > > 2019-01-25  Marek Polacek  <polacek@redhat.com>
> > > >
> > > >         PR c++/89024 - ICE with incomplete enum type.
> > > >         * call.c (standard_conversion): When converting an
> > > >         ARITHMETIC_TYPE_P to an incomplete type, return NULL.
> > >
> > > OK.
> > >
> >
> > Hi,
> > The new test fails on arm-eabi (with newlib, but passes on on arm*linux*):
> > FAIL: g++.dg/cpp0x/enum37.C  -std=c++14 (test for excess errors)
> > FAIL: g++.dg/cpp0x/enum37.C  -std=c++17 (test for excess errors)
> >
> > The log says:
> > /gcc/testsuite/g++.dg/cpp0x/enum37.C:24:41: error: aggregate
> > 'same<unsigned int, unsigned char> s2' has incomplete type and cannot
> > be defined

I imagine that this is because arm-eabi defaults to -fshort-enums; you
can check for this in the testsuite with { target short_enums }.

> Clearly the additional checking I added won't fly; Jason, can I commit
> this?
>
> Tested on x86_64-linux, ok for trunk?
>
> 2019-01-28  Marek Polacek  <polacek@redhat.com>
>
>         * g++.dg/cpp0x/enum37.C: Remove a check.

I'd prefer to make the check conditional.

Jason

  reply	other threads:[~2019-01-28 16:55 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-24 19:19 Marek Polacek
2019-01-24 22:17 ` Jason Merrill
2019-01-25 17:00   ` Tim Song
2019-01-25 17:13     ` Marek Polacek
2019-01-25 17:16       ` Jason Merrill
2019-01-26  1:25         ` Marek Polacek
2019-01-27  4:22           ` Jason Merrill
2019-01-28  9:48             ` Christophe Lyon
2019-01-28 16:37               ` Marek Polacek
2019-01-28 17:01                 ` Jason Merrill [this message]
2019-01-28 18:11                   ` Marek Polacek
2019-01-28 21:52                     ` Jason Merrill

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CADzB+2kvH8U-MRAiqqY+EoT9SMJ=dSr3L+dZW73xBeh96fJBLQ@mail.gmail.com' \
    --to=jason@redhat.com \
    --cc=christophe.lyon@linaro.org \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=polacek@redhat.com \
    --cc=t.canens.cpp@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).