llnl / llnl/rose

ROSE output for environment-dependent macros is incorrect

Open
#354 0 comments 0 reactions 1 assignee View on GitHub

@pinnown is already working on this.

Since Sep 8, 2020.

Dominant language
C
Stars
688
Forks
144
PR merge metrics
No merged PRs in 30d

Description

ROSE does not correctly define the predefined macros for the environment specified. The following file test.c is an example. If __GNUC__ is defined, NOINLINE should be __attribute__((noinline)). If _MSC_VER is defined, NOINLINE should be __declspec(noinline). However, both show up in the resulting rose_test.c file.

#if defined(__GNUC__)
#  define NOINLINE  __attribute__((noinline))
#elif defined(_MSC_VER) && _MSC_VER>=1310
#  define NOINLINE  __declspec(noinline)
#else
#  define NOINLINE
#endif


NOINLINE int add(int a, int b) 
{ 
    return a + b;
}

int main(int argc, char **argv) {
    return 0;
}

If this is passed through ROSE the resulting output file rose_test.c is as follows:

#if defined(__GNUC__)
#  define NOINLINE  __attribute__((noinline))
#elif defined(_MSC_VER) && _MSC_VER>=1310
#  define NOINLINE  __declspec(noinline)
#else
#  define NOINLINE
#endif

__declspec(noinline) int  __attribute__((noinline)) add(int a,int b)
{
  return a + b;
}

int main(int argc,signed char **argv)
{
  return 0;
}

For some reason both __declspec (the MSVC syntax) and __attribute__ (Linux syntax) are in the function header. This will thus not compile.
Note: ROSE was compiled with flags --enable-microsoft-extensions and --with-wine.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.