]> granicus.if.org Git - clang/commitdiff
If we already set a primary base, don't set it to the first nearly empty base class.
authorAnders Carlsson <andersca@mac.com>
Tue, 22 Sep 2009 19:16:59 +0000 (19:16 +0000)
committerAnders Carlsson <andersca@mac.com>
Tue, 22 Sep 2009 19:16:59 +0000 (19:16 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82563 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/RecordLayoutBuilder.cpp
test/SemaCXX/primary-base.cpp [new file with mode: 0644]

index 836e43c43afc8c2f5a4e2b302e449b265a64691a..8a3e08965f4d8952359c567702ddf682dc938bb1 100644 (file)
@@ -158,8 +158,8 @@ void ASTRecordLayoutBuilder::SelectPrimaryBase(const CXXRecordDecl *RD) {
 
   // Otherwise if is the first nearly empty virtual base, if one exists,
   // otherwise there is no primary base class.
-  setPrimaryBase(FirstPrimary, true);
-  return;
+  if (!PrimaryBase)
+    setPrimaryBase(FirstPrimary, true);
 }
 
 void ASTRecordLayoutBuilder::LayoutVirtualBase(const CXXRecordDecl *RD) {
diff --git a/test/SemaCXX/primary-base.cpp b/test/SemaCXX/primary-base.cpp
new file mode 100644 (file)
index 0000000..62f9087
--- /dev/null
@@ -0,0 +1,11 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+class A { virtual void f(); };
+class B : virtual A { };
+
+class C : B { };
+
+// Since A is already a primary base class, C should be the primary base class of F.
+class F : virtual A, virtual C { };
+
+int sa[sizeof(F) == sizeof(A) ? 1 : -1];
+