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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107864
91177308-0d34-0410-b5e6-
96231b3b80d8
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">;
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<
// 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;
}
}
void g() __attribute__((deprecated));
void g();
-void z() __attribute__((bogusattr)); // expected-warning {{'bogusattr' attribute ignored}}
-
extern int var __attribute__((deprecated));
int a() {
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}}
--- /dev/null
+// 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}}