]> granicus.if.org Git - clang/commitdiff
When marking derived classes' virtual methods ODR-used in order to trigger
authorNick Lewycky <nicholas@mxc.ca>
Thu, 14 Feb 2013 00:55:17 +0000 (00:55 +0000)
committerNick Lewycky <nicholas@mxc.ca>
Thu, 14 Feb 2013 00:55:17 +0000 (00:55 +0000)
instantiation in order to permit devirtualization later in codegen, skip over
pure functions since those can't be devirtualization targets.

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

lib/Sema/SemaExpr.cpp
test/SemaCXX/undefined-internal.cpp

index 191683d33dba3eb99335e91c7e1e18fa65264f42..b3ba2dc4ae92724e5ac21e32002e91efe6f669e9 100644 (file)
@@ -11179,7 +11179,7 @@ static void MarkExprReferenced(Sema &SemaRef, SourceLocation Loc,
   if (!MostDerivedClassDecl)
     return;
   CXXMethodDecl *DM = MD->getCorrespondingMethodInClass(MostDerivedClassDecl);
-  if (!DM)
+  if (!DM || DM->isPure())
     return;
   SemaRef.MarkAnyDeclReferenced(Loc, DM, OdrUse);
 } 
index e8810adadfa5cd84dbda415b27c2dbbf50b94af8..839fdafb34188d86f8fe29c373282182b21f8367 100644 (file)
@@ -306,3 +306,20 @@ namespace test12 {
     Cls2 obj1((T7()));  // expected-note {{used here}}
   }
 }
+
+namespace test13 {
+  namespace {
+    struct X {
+      virtual void f() { }
+    };
+
+    struct Y : public X {
+      virtual void f() = 0;
+
+      virtual void g() {
+        X::f();
+      }
+    };
+  }
+}
+