To do so we have to wait until we know that the type of a variable has been
deduced. Sema::FinalizeDeclaration is the first callback that is used for
decl with or without initializers.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171458
91177308-0d34-0410-b5e6-
96231b3b80d8
// member, set the visibility of this variable.
if (NewVD->getLinkage() == ExternalLinkage && !DC->isRecord())
AddPushedVisibilityAttribute(NewVD);
-
- MarkUnusedFileScopedDecl(NewVD);
return NewVD;
}
if (!VD)
return;
+ if (VD->isFileVarDecl())
+ MarkUnusedFileScopedDecl(VD);
+
// Now we have parsed the initializer and can update the table of magic
// tag values.
if (!VD->hasAttr<TypeTagForDatatypeAttr>() ||
-// RUN: %clang_cc1 -fsyntax-only -verify -Wunused -Wunused-member-function -std=c++98 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wunused -Wunused-member-function -Wno-c++11-extensions -std=c++98 %s
// RUN: %clang_cc1 -fsyntax-only -verify -Wunused -Wunused-member-function -std=c++11 %s
static void f1(); // expected-warning{{unused}}
void bar();
};
}
+
+namespace pr14776 {
+ namespace {
+ struct X {};
+ }
+ X a = X(); // expected-warning {{unused variable 'a'}}
+ auto b = X(); // expected-warning {{unused variable 'b'}}
+}