Add support for differentiating between attributes ignored when handled and

unknown attributes that we discard. Add a diagnostic group for unknown
attribute warnings to allow turning these off when we don't care. Also
consolidates the tests for this case.

llvm-svn: 107864
This commit is contained in:
Chandler Carruth 2010-07-08 09:42:26 +00:00
parent b69d4ce5f3
commit dd1bc0f1b5
5 changed files with 10 additions and 4 deletions

View File

@ -116,6 +116,7 @@ def Trigraphs : DiagGroup<"trigraphs">;
def : DiagGroup<"type-limits">;
def Uninitialized : DiagGroup<"uninitialized">;
def UnknownPragmas : DiagGroup<"unknown-pragmas">;
def UnknownAttributes : DiagGroup<"unknown-attributes">;
def UnusedArgument : DiagGroup<"unused-argument">;
def UnusedExceptionParameter : DiagGroup<"unused-exception-parameter">;
def UnusedFunction : DiagGroup<"unused-function">;

View File

@ -875,6 +875,8 @@ 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_unknown_attribute_ignored : Warning<
"unknown attribute %0 ignored">, InGroup<UnknownAttributes>;
def warn_attribute_precede_definition : Warning<
"attribute declaration must precede definition">;
def warn_attribute_void_function_method : Warning<

View File

@ -2069,7 +2069,8 @@ static void ProcessDeclAttribute(Scope *scope, Decl *D,
// Ask target about the attribute.
const TargetAttributesSema &TargetAttrs = S.getTargetAttributesSema();
if (!TargetAttrs.ProcessDeclAttribute(scope, D, Attr, S))
S.Diag(Attr.getLoc(), diag::warn_attribute_ignored) << Attr.getName();
S.Diag(Attr.getLoc(), diag::warn_unknown_attribute_ignored)
<< Attr.getName();
break;
}
}

View File

@ -4,8 +4,6 @@ int f() __attribute__((deprecated));
void g() __attribute__((deprecated));
void g();
void z() __attribute__((bogusattr)); // expected-warning {{'bogusattr' attribute ignored}}
extern int var __attribute__((deprecated));
int a() {
@ -45,7 +43,7 @@ typedef struct foo foo_dep __attribute__((deprecated));
foo_dep *test2; // expected-warning {{'foo_dep' is deprecated}}
struct bar_dep __attribute__((deprecated,
invalid_attribute)); // expected-warning {{'invalid_attribute' attribute ignored}}
invalid_attribute)); // expected-warning {{unknown attribute 'invalid_attribute' ignored}}
struct bar_dep *test3; // expected-warning {{'bar_dep' is deprecated}}

View File

@ -0,0 +1,4 @@
// RUN: %clang_cc1 -fsyntax-only -verify -Wunknown-attributes %s
int x __attribute__((foobar)); // expected-warning {{unknown attribute 'foobar' ignored}}
void z() __attribute__((bogusattr)); // expected-warning {{unknown attribute 'bogusattr' ignored}}