]> granicus.if.org Git - clang/commitdiff
Mark TypeDecls used in explicit destructor calls as referenced.
authorNico Weber <nicolasweber@gmx.de>
Wed, 12 Nov 2014 04:33:52 +0000 (04:33 +0000)
committerNico Weber <nicolasweber@gmx.de>
Wed, 12 Nov 2014 04:33:52 +0000 (04:33 +0000)
Fixes PR21221. Patch by Axel Naumann, test by me.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@221771 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaExprCXX.cpp
test/SemaCXX/warn-unused-local-typedef.cpp

index b035f8ff49cc045106f48e76744f6c716a59cf50..5b861ad54586a33924ab5a81d2d1303cca0cad4d 100644 (file)
@@ -200,6 +200,7 @@ ParsedType Sema::getDestructorName(SourceLocation TildeLoc,
 
     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)) {
index 1ef0ebfe1acd6ef8c39a4c86cb40036c2914d2fe..a9406531d2d75501679e52e806b47b04937d4f11 100644 (file)
@@ -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"