Skip to content

Dump-c and inlining #302

Description

@danpoe

When using --dump-c together with inlining the resulting C program might not compile due to multiple definitions of a variable:

inline void func1() {
int i;
}
inline void func2() {
int i;
}
void main() {
func1();
func2();
}

--escape-analysis to trigger partial inlining:

goto-cc main.c
goto-instrument --escape-analysis --dump-c a.out

Dumped C program:

// func1
// file main.c line 2
inline void func1();
// func2
// file main.c line 6
inline void func2();
// func1
// file main.c line 2
inline void func1()
{
signed int i;
}
// func2
// file main.c line 6
inline void func2()
{
signed int i;
}
// main
// file main.c line 10
void main()
{
signed int i;
signed int i;
}

gcc yields:

out.c: In function ‘main’:
out.c:28:14: error: redeclaration of ‘i’ with no linkage
signed int i;
^
out.c:27:14: note: previous declaration of ‘i’ was here
signed int i;

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions