https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85039

--- Comment #5 from Alexandre Oliva <aoliva at gcc dot gnu.org> ---
Author: aoliva
Date: Mon Apr 16 21:35:34 2018
New Revision: 259423

URL: https://gcc.gnu.org/viewcvs?rev=259423&root=gcc&view=rev
Log:
[PR c++/85039] no type definitions in builtin offsetof

Types defined within a __builtin_offsetof argument don't always get
properly recorded as members of their context types, so if they're
anonymous, we may fail to assign them an anon type index for mangling
and ICE.

We shouldn't allow types to be introduced in __builtin_offsetof, I
think, and Jason says the std committee agrees, so I've arranged for
us to reject them.

Even then, we still parse the definitions and attempt to assign
mangled names to its member functions, so the ICE remains.  Since
we've already reported an error, we might as well complete the name
assignment with an arbitrary index, thus avoiding the ICE.

We used to have a test that expected to be able to define types in
__builtin_offsetof; this patch removes that specific test.


for  gcc/cp/ChangeLog

        PR c++/85039
        * parser.c (cp_parser_builtin_offset): Reject type definitions.
        * mangle.c (nested_anon_class_index): Avoid crash returning -1
        if we've seen errors.

for  gcc/testsuite/ChangeLog

        PR c++/85039
        * g++.dg/pr85039-1.C: New.
        * g++.dg/pr85039-2.C: New.
        * g++.dg/parse/semicolon3.C: Remove test_offsetof.

Added:
    trunk/gcc/testsuite/g++.dg/pr85039-1.C
    trunk/gcc/testsuite/g++.dg/pr85039-2.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/mangle.c
    trunk/gcc/cp/parser.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/g++.dg/parse/semicolon3.C

Reply via email to