Skip to content

Rewriting bugs with re-solving of bounds declaration inside macro #595

Open
@mattmccutchen-cci

Description

@mattmccutchen-cci

Running 3c -alltypes on this code:

#define PARAM_DECL_WITH_BOUNDS int *p : count(5)
void foo1(PARAM_DECL_WITH_BOUNDS) {}

gives:

#define PARAM_DECL_WITH_BOUNDS int *p : count(5)
void foo1(PARAM_DECL_WITH_BOUNDS : count(5)) {}

This preprocesses to:

void foo1(int *p : count(5) : count(5)) {}

which is a syntax error.

In another case:

#define FUNCTION_DEF_WITH_BOUNDS void foo2(int *p : count(5)) {}
FUNCTION_DEF_WITH_BOUNDS

3c -alltypes reports an error:

/home/matt/test/resolve_bounds_in_macro_2.c:2:1: error: Unable to rewrite converted source range. Intended rewriting: "(int *p : count(5))"
FUNCTION_DEF_WITH_BOUNDS
^~~~~~~~~~~~~~~~~~~~~~~~
/home/matt/test/resolve_bounds_in_macro_2.c:1:43: note: expanded from macro 'FUNCTION_DEF_WITH_BOUNDS'
#define FUNCTION_DEF_WITH_BOUNDS void foo2(int *p : count(5)) {}
                                          ^

3C probably shouldn't be trying to modify the macro at all.

I decided to go ahead and file an issue because I noticed this in my tests related to #581. There may be other problems with itype / bounds re-solving and macros, but I imagine that all of these cases are unusual.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions