[cfe-commits] r107864 - in /cfe/trunk: include/clang/Basic/DiagnosticGroups.td include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaDeclAttr.cpp test/Sema/attr-deprecated.c test/Sema/attr-unknown.c
Chandler Carruth
chandlerc at gmail.com
Thu Jul 8 02:42:26 PDT 2010
Author: chandlerc
Date: Thu Jul 8 04:42:26 2010
New Revision: 107864
URL: http://llvm.org/viewvc/llvm-project?rev=107864&view=rev
Log:
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.
Added:
cfe/trunk/test/Sema/attr-unknown.c
Modified:
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/test/Sema/attr-deprecated.c
Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=107864&r1=107863&r2=107864&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Thu Jul 8 04:42:26 2010
@@ -116,6 +116,7 @@
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">;
Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=107864&r1=107863&r2=107864&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Jul 8 04:42:26 2010
@@ -875,6 +875,8 @@
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<
Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=107864&r1=107863&r2=107864&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Thu Jul 8 04:42:26 2010
@@ -2069,7 +2069,8 @@
// 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;
}
}
Modified: cfe/trunk/test/Sema/attr-deprecated.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/attr-deprecated.c?rev=107864&r1=107863&r2=107864&view=diff
==============================================================================
--- cfe/trunk/test/Sema/attr-deprecated.c (original)
+++ cfe/trunk/test/Sema/attr-deprecated.c Thu Jul 8 04:42:26 2010
@@ -4,8 +4,6 @@
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 @@
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}}
Added: cfe/trunk/test/Sema/attr-unknown.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/attr-unknown.c?rev=107864&view=auto
==============================================================================
--- cfe/trunk/test/Sema/attr-unknown.c (added)
+++ cfe/trunk/test/Sema/attr-unknown.c Thu Jul 8 04:42:26 2010
@@ -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}}
More information about the cfe-commits
mailing list