Author: majnemer Date: Thu Nov 12 23:32:43 2015 New Revision: 253013 URL: http://llvm.org/viewvc/llvm-project?rev=253013&view=rev Log: [Sema] __is_constructible should return false for function types
While functions types are complete, they cannot be constructed. This fixes PR25513. Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp cfe/trunk/test/SemaCXX/type-traits.cpp Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=253013&r1=253012&r2=253013&view=diff ============================================================================== --- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original) +++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Thu Nov 12 23:32:43 2015 @@ -4084,12 +4084,13 @@ static bool evaluateTypeTrait(Sema &S, T return false; } - // Make sure the first argument is a complete type. - if (Args[0]->getType()->isIncompleteType()) + // Make sure the first argument is not incomplete nor a function type. + QualType T = Args[0]->getType(); + if (T->isIncompleteType() || T->isFunctionType()) return false; // Make sure the first argument is not an abstract type. - CXXRecordDecl *RD = Args[0]->getType()->getAsCXXRecordDecl(); + CXXRecordDecl *RD = T->getAsCXXRecordDecl(); if (RD && RD->isAbstract()) return false; @@ -4097,13 +4098,13 @@ static bool evaluateTypeTrait(Sema &S, T SmallVector<Expr *, 2> ArgExprs; ArgExprs.reserve(Args.size() - 1); for (unsigned I = 1, N = Args.size(); I != N; ++I) { - QualType T = Args[I]->getType(); - if (T->isObjectType() || T->isFunctionType()) - T = S.Context.getRValueReferenceType(T); + QualType ArgTy = Args[I]->getType(); + if (ArgTy->isObjectType() || ArgTy->isFunctionType()) + ArgTy = S.Context.getRValueReferenceType(ArgTy); OpaqueArgExprs.push_back( - OpaqueValueExpr(Args[I]->getTypeLoc().getLocStart(), - T.getNonLValueExprType(S.Context), - Expr::getValueKindForType(T))); + OpaqueValueExpr(Args[I]->getTypeLoc().getLocStart(), + ArgTy.getNonLValueExprType(S.Context), + Expr::getValueKindForType(ArgTy))); } for (Expr &E : OpaqueArgExprs) ArgExprs.push_back(&E); @@ -4134,7 +4135,7 @@ static bool evaluateTypeTrait(Sema &S, T // Under Objective-C ARC, if the destination has non-trivial Objective-C // lifetime, this is a non-trivial construction. if (S.getLangOpts().ObjCAutoRefCount && - hasNontrivialObjCLifetime(Args[0]->getType().getNonReferenceType())) + hasNontrivialObjCLifetime(T.getNonReferenceType())) return false; // The initialization succeeded; now make sure there are no non-trivial Modified: cfe/trunk/test/SemaCXX/type-traits.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/type-traits.cpp?rev=253013&r1=253012&r2=253013&view=diff ============================================================================== --- cfe/trunk/test/SemaCXX/type-traits.cpp (original) +++ cfe/trunk/test/SemaCXX/type-traits.cpp Thu Nov 12 23:32:43 2015 @@ -1991,6 +1991,9 @@ void constructible_checks() { // PR20228 { int arr[T(__is_constructible(VariadicCtor, int, int, int, int, int, int, int, int, int))]; } + + // PR25513 + { int arr[F(__is_constructible(int(int)))]; } } // Instantiation of __is_trivially_constructible _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits