access-softek / msp430-clang

0 stars 2 forks source link

Diagnostic for interrupt attribute in case of K&R declaration #81

Open chbessonova opened 5 years ago

chbessonova commented 5 years ago

'Interrupt' attribute only applies to a function with no arguments (i.e., void foo(void);). But in the case of K&R style function declaration in C, there is no information about function arguments (it may have any number of arguments and don't have arguments at all as well). So, this case passes through frontend with no errors/warnings and causes a failure in the backend:

__attribute__((interrupt(0))) void foo();

void foo(int i) {
  i++;
}

fatal error: error in backend: ISRs cannot have arguments.

This should be detected and diagnosed early. The discussion started at https://reviews.llvm.org/D56663.