[cfe-dev] Inline attribute

Renato Golin renato.golin at linaro.org
Sat Mar 22 10:37:15 PDT 2014


Folks,

Behan sent me a piece of code in the kernel with a parsing issue in
Clang related to attributes:

This works on GCC, but not on Clang:
typedef unsigned char u8;
int func(int len, int mask) {
  return len + (mask & ~(__alignof__(u8 __attribute__ ((aligned))) - 1));
}

Clang's warning on the first is:
  * 'aligned' attribute ignored when parsing type

This fixes on Clang, too:
typedef unsigned char u8;
int func(int len, int mask) {
  typedef u8 __attribute__ ((aligned)) u8_aligned;
  return len + (mask & ~(__alignof__(u8_aligned) - 1));
}

I'm guessing Clang doesn't like inlined attributes. Is there a reason
why this is not implemented, or is this just a case that nobody has
seen before?

If the former, what reason? If the latter, how simple would it be to
implement it?

cheers,
--renato



More information about the cfe-dev mailing list