forked from OSchip/llvm-project
Fix diagnostic for bad alignas use: it can't be applied to functions.
llvm-svn: 174160
This commit is contained in:
parent
9c7eb1d887
commit
9eaab4be04
|
@ -1852,7 +1852,8 @@ def warn_attribute_wrong_decl_type : Warning<
|
|||
"functions, methods and blocks|functions, methods, and classes|"
|
||||
"functions, methods, and parameters|classes|variables|methods|"
|
||||
"variables, functions and labels|fields and global variables|structs|"
|
||||
"variables, functions and tag types|thread-local variables}1">,
|
||||
"variables, functions and tag types|thread-local variables|"
|
||||
"variables and fields|variables, data members and tag types}1">,
|
||||
InGroup<IgnoredAttributes>;
|
||||
def err_attribute_wrong_decl_type : Error<
|
||||
"%0 attribute only applies to %select{functions|unions|"
|
||||
|
@ -1860,7 +1861,8 @@ def err_attribute_wrong_decl_type : Error<
|
|||
"functions, methods and blocks|functions, methods, and classes|"
|
||||
"functions, methods, and parameters|classes|variables|methods|"
|
||||
"variables, functions and labels|fields and global variables|structs|"
|
||||
"variables, functions and tag types|thread-local variables}1">;
|
||||
"variables, functions and tag types|thread-local variables|"
|
||||
"variables and fields|variables, data members and tag types}1">;
|
||||
def warn_function_attribute_wrong_type : Warning<
|
||||
"'%0' only applies to function types; type here is %1">,
|
||||
InGroup<IgnoredAttributes>;
|
||||
|
|
|
@ -47,7 +47,9 @@ enum AttributeDeclKind {
|
|||
ExpectedFieldOrGlobalVar,
|
||||
ExpectedStruct,
|
||||
ExpectedVariableFunctionOrTag,
|
||||
ExpectedTLSVar
|
||||
ExpectedTLSVar,
|
||||
ExpectedVariableOrField,
|
||||
ExpectedVariableFieldOrTag
|
||||
};
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
@ -3323,7 +3325,8 @@ void Sema::AddAlignedAttr(SourceRange AttrRange, Decl *D, Expr *E,
|
|||
} else if (!isa<TagDecl>(D)) {
|
||||
Diag(AttrLoc, diag::err_attribute_wrong_decl_type)
|
||||
<< (TmpAttr.isC11() ? "'_Alignas'" : "'alignas'")
|
||||
<< ExpectedVariableFunctionOrTag;
|
||||
<< (TmpAttr.isC11() ? ExpectedVariableOrField
|
||||
: ExpectedVariableFieldOrTag);
|
||||
return;
|
||||
}
|
||||
if (DiagKind != -1) {
|
||||
|
|
|
@ -11,7 +11,7 @@ struct align_member {
|
|||
_Alignas(1) char bitfield : 1; // expected-error {{'_Alignas' attribute cannot be applied to a bit-field}}
|
||||
};
|
||||
|
||||
typedef _Alignas(8) char align_typedef; // expected-error {{'_Alignas' attribute only applies to variables, functions and tag types}}
|
||||
typedef _Alignas(8) char align_typedef; // expected-error {{'_Alignas' attribute only applies to variables and fields}}
|
||||
|
||||
void f(_Alignas(1) char c) { // expected-error {{'_Alignas' attribute cannot be applied to a function parameter}}
|
||||
_Alignas(1) register char k; // expected-error {{'_Alignas' attribute cannot be applied to a variable with 'register' storage class}}
|
||||
|
|
|
@ -25,7 +25,7 @@ template <unsigned A> struct alignas(A) align_class_template {};
|
|||
template <typename... T> alignas(T...) struct align_class_temp_pack_type {}; // expected-error{{pack expansions in alignment specifiers are not supported yet}}
|
||||
template <unsigned... A> alignas(A...) struct align_class_temp_pack_expr {}; // expected-error{{pack expansions in alignment specifiers are not supported yet}}
|
||||
|
||||
typedef char align_typedef alignas(8); // expected-error {{'alignas' attribute only applies to variables, functions and tag types}}
|
||||
typedef char align_typedef alignas(8); // expected-error {{'alignas' attribute only applies to variables, data members and tag types}}
|
||||
template<typename T> using align_alias_template = align_typedef alignas(8); // expected-error {{'alignas' attribute cannot be applied to types}}
|
||||
|
||||
static_assert(alignof(align_big) == alignof(int), "k's alignment is wrong"); // expected-warning{{'alignof' applied to an expression is a GNU extension}}
|
||||
|
|
Loading…
Reference in New Issue