
EnumArgument may be a string or an identifier. If it is a string, it should be parsed as unevaluated string literal. Add IsString flag to EnumArgument so that the parser can choose the correct parsing method. Target-specific attributes that share spelling may have different attribute "prototypes". For example, ARM's version of "interrupt" attribute accepts a string enum, while MSP430's version accepts an unsigned integer. Adjust ClangAttrEmitter so that the generated `attributeStringLiteralListArg` returns the correct mask depending on target triple. It is worth noting that even after this change some string arguments are still parsed as identifiers or, worse, as expressions. This is because of some special logic in `ParseAttributeArgsCommon`. Fixing it is out of scope of this patch.
24 lines
1.0 KiB
C
24 lines
1.0 KiB
C
// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -verify %s
|
|
|
|
__attribute__((function_return("keep"))) void x(void) {}
|
|
|
|
// expected-warning@+1 {{'function_return' attribute argument not supported: thunk}}
|
|
__attribute__((function_return("thunk"))) void y(void) {}
|
|
|
|
// expected-warning@+1 {{'function_return' attribute argument not supported: thunk-inline}}
|
|
__attribute__((function_return("thunk-inline"))) void z(void) {}
|
|
|
|
__attribute__((function_return("thunk-extern"))) void w(void) {}
|
|
|
|
// expected-warning@+1 {{'function_return' attribute argument not supported: invalid}}
|
|
__attribute__((function_return("invalid"))) void v(void) {}
|
|
|
|
// expected-error@+1 {{expected string literal as argument of 'function_return' attribute}}
|
|
__attribute__((function_return(5))) void a(void) {}
|
|
|
|
// expected-error@+1 {{'function_return' attribute takes one argument}}
|
|
__attribute__((function_return)) void b(void) {}
|
|
|
|
// expected-warning@+1 {{'function_return' attribute only applies to functions}}
|
|
__attribute__((function_return)) int c;
|