[cfe-commits] r95939 - in /cfe/trunk: include/clang/Basic/DiagnosticGroups.td include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/TargetAttributesSema.cpp test/Sema/x86-attr-force-align-arg-pointer.c
Douglas Gregor
dgregor at apple.com
Thu Feb 11 16:01:58 PST 2010
On Feb 11, 2010, at 3:57 PM, Charles Davis wrote:
> Author: cdavis
> Date: Thu Feb 11 17:57:08 2010
> New Revision: 95939
>
> URL: http://llvm.org/viewvc/llvm-project?rev=95939&view=rev
> Log:
> 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.
Thanks!
- Doug
> Modified:
> cfe/trunk/include/clang/Basic/DiagnosticGroups.td
> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> cfe/trunk/lib/Sema/TargetAttributesSema.cpp
> cfe/trunk/test/Sema/x86-attr-force-align-arg-pointer.c
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=95939&r1=95938&r2=95939&view=diff
>
> ==============================================================================
> --- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Thu Feb 11 17:57:08 2010
> @@ -119,6 +119,7 @@
> 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 @@
> // 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]>;
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=95939&r1=95938&r2=95939&view=diff
>
> ==============================================================================
> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Feb 11 17:57:08 2010
> @@ -722,6 +722,9 @@
> 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<
>
> Modified: cfe/trunk/lib/Sema/TargetAttributesSema.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/TargetAttributesSema.cpp?rev=95939&r1=95938&r2=95939&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/Sema/TargetAttributesSema.cpp (original)
> +++ cfe/trunk/lib/Sema/TargetAttributesSema.cpp Thu Feb 11 17:57:08 2010
> @@ -79,12 +79,14 @@
> 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)
>
> Modified: cfe/trunk/test/Sema/x86-attr-force-align-arg-pointer.c
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/x86-attr-force-align-arg-pointer.c?rev=95939&r1=95938&r2=95939&view=diff
>
> ==============================================================================
> --- cfe/trunk/test/Sema/x86-attr-force-align-arg-pointer.c (original)
> +++ cfe/trunk/test/Sema/x86-attr-force-align-arg-pointer.c Thu Feb 11 17:57:08 2010
> @@ -14,5 +14,5 @@
> 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}}
>
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
More information about the cfe-commits
mailing list