r221771 - Mark TypeDecls used in explicit destructor calls as referenced.
Nico Weber
nicolasweber at gmx.de
Tue Nov 11 20:33:52 PST 2014
Author: nico
Date: Tue Nov 11 22:33:52 2014
New Revision: 221771
URL: http://llvm.org/viewvc/llvm-project?rev=221771&view=rev
Log:
Mark TypeDecls used in explicit destructor calls as referenced.
Fixes PR21221. Patch by Axel Naumann, test by me.
Modified:
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/test/SemaCXX/warn-unused-local-typedef.cpp
Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=221771&r1=221770&r2=221771&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Tue Nov 11 22:33:52 2014
@@ -200,6 +200,7 @@ ParsedType Sema::getDestructorName(Sourc
if (TypeDecl *Type = Found.getAsSingle<TypeDecl>()) {
QualType T = Context.getTypeDeclType(Type);
+ MarkAnyDeclReferenced(Type->getLocation(), Type, /*OdrUse=*/false);
if (SearchType.isNull() || SearchType->isDependentType() ||
Context.hasSameUnqualifiedType(T, SearchType)) {
Modified: cfe/trunk/test/SemaCXX/warn-unused-local-typedef.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-unused-local-typedef.cpp?rev=221771&r1=221770&r2=221771&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/warn-unused-local-typedef.cpp (original)
+++ cfe/trunk/test/SemaCXX/warn-unused-local-typedef.cpp Tue Nov 11 22:33:52 2014
@@ -225,5 +225,18 @@ void typedefs_in_constructors() {
};
}
+void *operator new(__SIZE_TYPE__, void *p) throw() { return p; }
+void placement_new_and_delete() {
+ struct MyStruct { };
+ char memory[sizeof(MyStruct)];
+ void *p = memory;
+
+ typedef MyStruct A_t1;
+ MyStruct *a = new (p) A_t1();
+
+ typedef MyStruct A_t2;
+ a->~A_t2();
+}
+
// This should not disable any warnings:
#pragma clang diagnostic ignored "-Wunused-local-typedef"
More information about the cfe-commits
mailing list