Skip to content

token concatenation is buggy #11

@eriklovlie

Description

@eriklovlie

The following test fails:

`define SIZE 42
`define D(a) `SIZE``a
`D('d0)

It fails during macro expansion because SIZE'd0 is used as the full macro target, and not just SIZE. The reason is the logic that deals with the following (i.e. concatenation which leads to a recursive macro call):

`define FOO(TYPE,ARG,FLAG) `M_UVM_``TYPE(ARG,FLAG)
`define M_UVM_ARRAY(arg1, arg2) yo
`FOO(ARRAY, byte_valid, UVM_NOPACK)

So the former currently fails and the latter works. Obviously SIZE'd0 cannot be a legal macro name, but that's irrelevant here. When the macro text in D is scanned we can't know whether it will expand to a new macro call SIZE_rest_of_macro_name or 42'd0.

The LRM doesn't appear to be very clear on the rules here and there is not much available example code except for the latter example above (from the uvm reference implementation).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions