InGroup<UnusedFunction>, DefaultIgnore;
def warn_unused_member_function : Warning<"unused member function %0">,
InGroup<UnusedMemberFunction>, DefaultIgnore;
-
+def warn_used_but_marked_unused: Warning<"%0 was marked unused but was used">,
+ InGroup<Unused>;
+
def warn_implicit_function_decl : Warning<
"implicit declaration of function %0">,
InGroup<ImplicitFunctionDeclare>, DefaultIgnore;
continue;
}
+ // Warn if this was used before being marked unused.
+ if (VD->isUsed())
+ Diag(PragmaLoc, diag::warn_used_but_marked_unused) << Name;
+
VD->addAttr(::new (Context) UnusedAttr(Tok.getLocation(), Context));
}
}
}
}
+ // Warn if this is used but marked unused.
+ if (D->hasAttr<UnusedAttr>())
+ Diag(Loc, diag::warn_used_but_marked_unused) << D->getDeclName();
+
return false;
}
// -Wunused-parameters)
if (isa<ParmVarDecl>(D) ||
(isa<VarDecl>(D) && D->getDeclContext()->isFunctionOrMethod())) {
- D->setUsed(true);
+ D->setUsed();
return;
}
double __Foo_READSWAP__double(double*);
static __inline__ bar_return_t
-__Beeble_check__Request__SetPortalSize_t(__attribute__((__unused__)) __Request__SetPortalSize_t *In0P) {
+__Beeble_check__Request__SetPortalSize_t(__Request__SetPortalSize_t *In0P) {
if (In0P->Foo.int_rep != Foo_record.int_rep) {
do {
int __i__, __C__ = (2);
-// RUN: %clang_cc1 -verify -Wunused-variable -fsyntax-only %s
+// RUN: %clang_cc1 -verify -Wunused -Wunused-parameter -Wunused -fsyntax-only %s
static void (*fp0)(void) __attribute__((unused));
int x; // expected-warning {{unused variable}}
Int_not_unused i0; // expected-warning {{unused variable}}
- Int_unused i1;
+ Int_unused i1; // expected-warning {{'Int_unused' was marked unused but was used}}
struct Test0_not_unused s0; // expected-warning {{unused variable}}
- struct Test0_unused s1;
+ struct Test0_unused s1; // expected-warning {{'Test0_unused' was marked unused but was used}}
+}
+
+int f3(int x) { // expected-warning{{unused parameter 'x'}}
+ return 0;
+}
+
+int f4(int x) {
+ return x;
+}
+
+int f5(int x __attribute__((__unused__))) {
+ return 0;
+}
+
+int f6(int x __attribute__((__unused__))) {
+ return x; // expected-warning{{'x' was marked unused but was used}}
}
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wunused-parameter -verify %s
void f1(void) {
int x, y, z;
#pragma unused(undeclared, undefined, y) // expected-warning{{undeclared variable 'undeclared' used as an argument for '#pragma unused'}} expected-warning{{undeclared variable 'undefined' used as an argument for '#pragma unused'}}
}
+int f8(int x) { // expected-warning{{unused parameter 'x'}}
+ return 0;
+}
+
+int f9(int x) {
+ return x;
+}
+
+int f10(int x) {
+ #pragma unused(x)
+ return 0;
+}
+
+int f11(int x) {
+ #pragma unused(x)
+ return x; // expected-warning{{'x' was marked unused but was used}}
+}
+
+int f12(int x) {
+ int y = x;
+ #pragma unused(x) // expected-warning{{'x' was marked unused but was used}}
+ return y;
+}