Re: [PATCH 9/9] C++ compile support

Simon Marchi via Gdb-patches
2021-03-24T01:04:19Z

Hi Keith,

I am from the past...

On 2018-08-10 7:25 p.m., Keith Seitz wrote:
> +/* Convert a struct or union type to its gcc representation. If this type
> + was defined in another type, NESTED_ACCESS should indicate the
> + accessibility of this type. */
> +
> +static gcc_type
> +compile_cplus_convert_struct_or_union (compile_cplus_instance *instance,
> + struct type *type,
> + enum gcc_cp_symbol_kind nested_access)
> +{
> + const char *filename = nullptr;
> + unsigned short line = 0;
> +
> + /* Get the decl name of this type. */
> + gdb::unique_xmalloc_ptr<char> name = decl_name (TYPE_NAME (type));
> +
> + /* Create a new scope for TYPE. */
> + compile_scope scope = instance->new_scope (TYPE_NAME (type), type);
> +
> + if (scope.nested_type () != GCC_TYPE_NONE)
> + {
> + /* The type requested was actually defined inside another type,
> + such as a nested class definition. Return that type. */
> + return scope.nested_type ();
> + }
> +
> + /* Push all scopes. */
> + instance->enter_scope (scope);
> +
> + /* First we create the resulting type and enter it into our hash
> + table. This lets recursive types work. */
> +
> + gcc_decl resuld;
> + if (TYPE_CODE (type) == TYPE_CODE_STRUCT)
> + {
> + const char *what = TYPE_DECLARED_CLASS (type) ? "struct" : "class";

I don't know if this matters, but the condition above looks reversed,
can you confirm?

Simon