[cfe-commits] r99661 - in /cfe/trunk: lib/Sema/SemaDeclCXX.cpp test/CodeGenCXX/constructor-init.cpp
Douglas Gregor
dgregor at apple.com
Fri Mar 26 15:43:08 PDT 2010
Author: dgregor
Date: Fri Mar 26 17:43:07 2010
New Revision: 99661
URL: http://llvm.org/viewvc/llvm-project?rev=99661&view=rev
Log:
When adding initializers to a constructor, be sure that we are looking
through the bases and fields of the definition of the class in which
the constructor is declared, rather than some other declaration of
that class.
Modified:
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/test/CodeGenCXX/constructor-init.cpp
Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=99661&r1=99660&r2=99661&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Fri Mar 26 17:43:07 2010
@@ -1433,7 +1433,11 @@
bool AnyErrors) {
// We need to build the initializer AST according to order of construction
// and not what user specified in the Initializers list.
- CXXRecordDecl *ClassDecl = cast<CXXRecordDecl>(Constructor->getDeclContext());
+ CXXRecordDecl *ClassDecl
+ = cast<CXXRecordDecl>(Constructor->getDeclContext())->getDefinition();
+ if (!ClassDecl)
+ return true;
+
llvm::SmallVector<CXXBaseOrMemberInitializer*, 32> AllToInit;
llvm::DenseMap<const void *, CXXBaseOrMemberInitializer*> AllBaseFields;
bool HasDependentBaseInit = false;
Modified: cfe/trunk/test/CodeGenCXX/constructor-init.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/constructor-init.cpp?rev=99661&r1=99660&r2=99661&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/constructor-init.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/constructor-init.cpp Fri Mar 26 17:43:07 2010
@@ -80,3 +80,24 @@
// CHECK-NOT: call void @_ZN1AIsED1Ev
// CHECK: ret void
}
+
+template<typename T>
+struct X {
+ X(const X &);
+
+ T *start;
+ T *end;
+};
+
+template<typename T> struct X;
+
+// Make sure that the instantiated constructor initializes start and
+// end properly.
+// CHECK: define linkonce_odr void @_ZN1XIiEC2ERKS0_
+// CHECK: {{store.*null}}
+// CHECK: {{store.*null}}
+// CHECK: ret
+template<typename T>
+X<T>::X(const X &other) : start(0), end(0) { }
+
+X<int> get_X(X<int> x) { return x; }
More information about the cfe-commits
mailing list