diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-11-13 23:14:53 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-11-13 23:14:53 +0000 |
commit | cad84b7c12564ff37feb66d6d004bb609bea8788 (patch) | |
tree | afab19a2565e6069b475747c8b4946490d59d94a /lib/AST/DeclCXX.cpp | |
parent | 65d0e28583ac050ec9aa71b469285faad48d137e (diff) |
A constructor template cannot be instantiated to a copy
constructor. Make sure that such declarations can never be formed.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@88718 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/DeclCXX.cpp')
-rw-r--r-- | lib/AST/DeclCXX.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/lib/AST/DeclCXX.cpp b/lib/AST/DeclCXX.cpp index e325a25c76..69a577f1e7 100644 --- a/lib/AST/DeclCXX.cpp +++ b/lib/AST/DeclCXX.cpp @@ -707,23 +707,23 @@ CXXConstructorDecl::isCopyConstructor(ASTContext &Context, // if its first parameter is of type X&, const X&, volatile X& or // const volatile X&, and either there are no other parameters // or else all other parameters have default arguments (8.3.6). + // + // Note that we also test cv 'X' as a copy constructor, even though it is + // ill-formed, because this helps enforce C++ [class.copy]p3. if ((getNumParams() < 1) || (getNumParams() > 1 && !getParamDecl(1)->hasDefaultArg()) || - (getPrimaryTemplate() != 0) || (getDescribedFunctionTemplate() != 0)) return false; const ParmVarDecl *Param = getParamDecl(0); // Do we have a reference type? Rvalue references don't count. - const LValueReferenceType *ParamRefType = - Param->getType()->getAs<LValueReferenceType>(); - if (!ParamRefType) - return false; + CanQualType PointeeType = Context.getCanonicalType(Param->getType()); + if (CanQual<LValueReferenceType> ParamRefType = + PointeeType->getAs<LValueReferenceType>()) + PointeeType = ParamRefType->getPointeeType(); - // Is it a reference to our class type? - CanQualType PointeeType - = Context.getCanonicalType(ParamRefType->getPointeeType()); + // Do we have our class type? CanQualType ClassTy = Context.getCanonicalType(Context.getTagDeclType(getParent())); if (PointeeType.getUnqualifiedType() != ClassTy) |