/// \brief Set the constructor that this inheriting constructor is based on.
void setInheritedConstructor(const CXXConstructorDecl *BaseCtor);
+
+ const CXXConstructorDecl *getCanonicalDecl() const {
+ return cast<CXXConstructorDecl>(FunctionDecl::getCanonicalDecl());
+ }
+ CXXConstructorDecl *getCanonicalDecl() {
+ return cast<CXXConstructorDecl>(FunctionDecl::getCanonicalDecl());
+ }
// Implement isa/cast/dyncast/etc.
static bool classof(const Decl *D) { return classofKind(D->getKind()); }
bool
Sema::SetDelegatingInitializer(CXXConstructorDecl *Constructor,
CXXCtorInitializer *Initializer) {
- // FIXME: This doesn't catch indirect loops yet
CXXConstructorDecl *Target = Initializer->getTargetConstructor();
+ CXXConstructorDecl *Canonical = Constructor->getCanonicalDecl();
while (Target) {
- if (Target == Constructor) {
+ if (Target->getCanonicalDecl() == Canonical) {
Diag(Initializer->getSourceLocation(), diag::err_delegating_ctor_loop)
<< Constructor;
return true;
foo::foo (const float* f) : foo(*f) {
}
-// FIXME: This should error
-foo::foo (const float &f) : foo(&f) {
+foo::foo (const float &f) : foo(&f) { //expected-error{{delegates to itself}}
}
foo::foo (char) : i(3), foo(3) { // expected-error{{must appear alone}}