[cfe-commits] r90682 - in /cfe/trunk: lib/Sema/SemaDeclCXX.cpp test/SemaTemplate/template-class-traits.cpp
Eli Friedman
eli.friedman at gmail.com
Sat Dec 5 15:03:49 PST 2009
Author: efriedma
Date: Sat Dec 5 17:03:49 2009
New Revision: 90682
URL: http://llvm.org/viewvc/llvm-project?rev=90682&view=rev
Log:
Fix for PR5693: shift some code into SetClassDeclAttributesFromBase so that
it gets called during template instantiation.
Added:
cfe/trunk/test/SemaTemplate/template-class-traits.cpp
Modified:
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=90682&r1=90681&r2=90682&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Sat Dec 5 17:03:49 2009
@@ -484,10 +484,7 @@
assert(BaseDecl && "Base type is not incomplete, but has no definition");
CXXRecordDecl * CXXBaseDecl = cast<CXXRecordDecl>(BaseDecl);
assert(CXXBaseDecl && "Base type is not a C++ type");
- if (!CXXBaseDecl->isEmpty())
- Class->setEmpty(false);
- if (CXXBaseDecl->isPolymorphic())
- Class->setPolymorphic(true);
+
// C++0x CWG Issue #817 indicates that [[final]] classes shouldn't be bases.
if (CXXBaseDecl->hasAttr<FinalAttr>()) {
Diag(BaseLoc, diag::err_final_base) << BaseType.getAsString();
@@ -496,7 +493,7 @@
return 0;
}
- SetClassDeclAttributesFromBase(Class, cast<CXXRecordDecl>(BaseDecl), Virtual);
+ SetClassDeclAttributesFromBase(Class, CXXBaseDecl, Virtual);
// Create the base specifier.
// FIXME: Allocate via ASTContext?
@@ -508,10 +505,23 @@
void Sema::SetClassDeclAttributesFromBase(CXXRecordDecl *Class,
const CXXRecordDecl *BaseClass,
bool BaseIsVirtual) {
+ // A class with a non-empty base class is not empty.
+ // FIXME: Standard ref?
+ if (!BaseClass->isEmpty())
+ Class->setEmpty(false);
+
+ // C++ [class.virtual]p1:
+ // A class that [...] inherits a virtual function is called a polymorphic
+ // class.
+ if (BaseClass->isPolymorphic())
+ Class->setPolymorphic(true);
// C++ [dcl.init.aggr]p1:
// An aggregate is [...] a class with [...] no base classes [...].
Class->setAggregate(false);
+
+ // C++ [class]p4:
+ // A POD-struct is an aggregate class...
Class->setPOD(false);
if (BaseIsVirtual) {
Added: cfe/trunk/test/SemaTemplate/template-class-traits.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/template-class-traits.cpp?rev=90682&view=auto
==============================================================================
--- cfe/trunk/test/SemaTemplate/template-class-traits.cpp (added)
+++ cfe/trunk/test/SemaTemplate/template-class-traits.cpp Sat Dec 5 17:03:49 2009
@@ -0,0 +1,8 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+#define T(b) (b) ? 1 : -1
+#define F(b) (b) ? -1 : 1
+
+struct HasVirt { virtual void a(); };
+template<class T> struct InheritPolymorph : HasVirt {};
+int t01[T(__is_polymorphic(InheritPolymorph<int>))];
+
More information about the cfe-commits
mailing list