From: Nikola Smiljanic Date: Tue, 15 Apr 2014 11:30:15 +0000 (+0000) Subject: PR19178 __is_constructible returns true for abstract types. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0ada62c58565b4f5b827553fcbe5717fcfb81570;p=clang PR19178 __is_constructible returns true for abstract types. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@206273 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp index 8b9c0e2cc7..e3bb944917 100644 --- a/lib/Sema/SemaExprCXX.cpp +++ b/lib/Sema/SemaExprCXX.cpp @@ -3656,6 +3656,11 @@ static bool evaluateTypeTrait(Sema &S, TypeTrait Kind, SourceLocation KWLoc, if (Args[0]->getType()->isIncompleteType()) return false; + // Make sure the first argument is not an abstract type. + CXXRecordDecl *RD = Args[0]->getType()->getAsCXXRecordDecl(); + if (RD && RD->isAbstract()) + return false; + SmallVector OpaqueArgExprs; SmallVector ArgExprs; ArgExprs.reserve(Args.size() - 1); diff --git a/test/SemaCXX/type-traits.cpp b/test/SemaCXX/type-traits.cpp index 28fb8dc749..3b94ef0951 100644 --- a/test/SemaCXX/type-traits.cpp +++ b/test/SemaCXX/type-traits.cpp @@ -1964,6 +1964,10 @@ void constructible_checks() { { int arr[T(__is_constructible(NonPOD, int))]; } { int arr[F(__is_nothrow_constructible(NonPOD, int))]; } + + // PR19178 + { int arr[F(__is_constructible(Abstract))]; } + { int arr[F(__is_nothrow_constructible(Abstract))]; } } // Instantiation of __is_trivially_constructible @@ -1991,6 +1995,7 @@ void is_trivially_constructible_test() { { int arr[F((is_trivially_constructible::value))]; } { int arr[F((is_trivially_constructible::value))]; } { int arr[F((is_trivially_constructible::value))]; } + { int arr[F((is_trivially_constructible::value))]; } // PR19178 } void array_rank() {