Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

token concatenation is buggy #11

Open
eriklovlie opened this issue Sep 20, 2015 · 1 comment
Open

token concatenation is buggy #11

eriklovlie opened this issue Sep 20, 2015 · 1 comment

Comments

@eriklovlie
Copy link
Collaborator

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).

@eriklovlie
Copy link
Collaborator Author

Let's say you have this case:

`define SIZE 1
`define SIZE23 hello
`define D(a) `SIZE``a
`D(23)

It's not clear to me whether the result should be 123 or hello.

svstuff pushed a commit that referenced this issue Sep 20, 2015
Terrible hack for issue #11. This fixes my immediate needs and
I will just have to await more example code to get a proper fix.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant