From 3ca83346b34304bb98a034c48fb3e99aa912a562 Mon Sep 17 00:00:00 2001 From: Charles Davis Date: Thu, 18 Feb 2010 04:39:19 +0000 Subject: [PATCH] Two fixes related to force_align_arg_pointer: - Also recognize __force_align_arg_pointer__. - Don't warn if it's used on a function pointer typedef. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96568 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/TargetAttributesSema.cpp | 9 +++++++-- test/Sema/x86-attr-force-align-arg-pointer.c | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/Sema/TargetAttributesSema.cpp b/lib/Sema/TargetAttributesSema.cpp index 76cff1f31..1ea029910 100644 --- a/lib/Sema/TargetAttributesSema.cpp +++ b/lib/Sema/TargetAttributesSema.cpp @@ -82,9 +82,13 @@ static void HandleX86ForceAlignArgPointerAttr(Decl *D, // 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. - ValueDecl* VD = dyn_cast(D); + ValueDecl *VD = dyn_cast(D); if (VD && VD->getType()->isFunctionPointerType()) return; + // Also don't warn on function pointer typedefs. + TypedefDecl *TD = dyn_cast(D); + if (TD && TD->getUnderlyingType()->isFunctionPointerType()) + return; // Attribute can only be applied to function types. if (!isa(D)) { S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type) @@ -189,7 +193,8 @@ namespace { default: break; } } - if (Attr.getName()->getName() == "force_align_arg_pointer") { + if (Attr.getName()->getName() == "force_align_arg_pointer" || + Attr.getName()->getName() == "__force_align_arg_pointer__") { HandleX86ForceAlignArgPointerAttr(D, Attr, S); return true; } diff --git a/test/Sema/x86-attr-force-align-arg-pointer.c b/test/Sema/x86-attr-force-align-arg-pointer.c index 1470544a6..5c7582fe0 100644 --- a/test/Sema/x86-attr-force-align-arg-pointer.c +++ b/test/Sema/x86-attr-force-align-arg-pointer.c @@ -15,4 +15,5 @@ void __attribute__((force_align_arg_pointer)) d(void) {} // Attribute is ignored on function pointer types. void (__attribute__((force_align_arg_pointer)) *p)(); +typedef void (__attribute__((__force_align_arg_pointer__)) *p2)();