forked from OSchip/llvm-project
Warn about using the new force_align_arg_pointer attribute on a function
pointer. If you don't like the new warning, you can turn it off with -Wno-force-align-arg-pointer. llvm-svn: 95939
This commit is contained in:
parent
93c92225af
commit
a90f7ca591
|
@ -119,6 +119,7 @@ def VectorConversions : DiagGroup<"vector-conversions">; // clang specific
|
|||
def VolatileRegisterVar : DiagGroup<"volatile-register-var">;
|
||||
def : DiagGroup<"write-strings">;
|
||||
def CharSubscript : DiagGroup<"char-subscripts">;
|
||||
def ForceAlignArgPointer : DiagGroup<"force-align-arg-pointer">;
|
||||
|
||||
// Aggregation warning settings.
|
||||
|
||||
|
@ -179,4 +180,4 @@ def : DiagGroup<"comments", [Comment]>; // -Wcomments = -Wcomment
|
|||
// A warning group for warnings that we want to have on by default in clang,
|
||||
// but which aren't on by default in GCC.
|
||||
def NonGCC : DiagGroup<"non-gcc",
|
||||
[SignCompare, Conversion]>;
|
||||
[SignCompare, Conversion, ForceAlignArgPointer]>;
|
||||
|
|
|
@ -722,6 +722,9 @@ def err_attribute_aligned_not_power_of_two : Error<
|
|||
def warn_redeclaration_without_attribute_prev_attribute_ignored : Warning<
|
||||
"'%0' redeclared without %1 attribute: previous %1 ignored">;
|
||||
def warn_attribute_ignored : Warning<"%0 attribute ignored">;
|
||||
def warn_faap_attribute_ignored : Warning<
|
||||
"force_align_arg_pointer used on function pointer; attribute ignored">,
|
||||
InGroup<ForceAlignArgPointer>;
|
||||
def warn_attribute_precede_definition : Warning<
|
||||
"attribute declaration must precede definition">;
|
||||
def warn_attribute_void_function : Warning<
|
||||
|
|
|
@ -79,12 +79,14 @@ static void HandleX86ForceAlignArgPointerAttr(Decl *D,
|
|||
return;
|
||||
}
|
||||
|
||||
// If we try to apply it to a function pointer, don't warn, but don't
|
||||
// do anything, either. It doesn't matter anyway, because there's nothing
|
||||
// special about calling a force_align_arg_pointer function.
|
||||
// If we try to apply it to a function pointer, warn. This is a special
|
||||
// instance of the warn_attribute_ignored warning that can be turned
|
||||
// off with -Wno-force-align-arg-pointer.
|
||||
ValueDecl* VD = dyn_cast<ValueDecl>(D);
|
||||
if (VD && VD->getType()->isFunctionPointerType())
|
||||
if (VD && VD->getType()->isFunctionPointerType()) {
|
||||
S.Diag(Attr.getLoc(), diag::warn_faap_attribute_ignored);
|
||||
return;
|
||||
}
|
||||
// Attribute can only be applied to function types.
|
||||
if (!isa<FunctionDecl>(D)) {
|
||||
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type)
|
||||
|
|
|
@ -14,5 +14,5 @@ void d(void);
|
|||
void __attribute__((force_align_arg_pointer)) d(void) {}
|
||||
|
||||
// Attribute is ignored on function pointer types.
|
||||
void (__attribute__((force_align_arg_pointer)) *p)();
|
||||
void (__attribute__((force_align_arg_pointer)) *p)(); //expected-warning{{force_align_arg_pointer used on function pointer; attribute ignored}}
|
||||
|
||||
|
|
Loading…
Reference in New Issue