diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp index 8b9c0e2cc7d5..e3bb944917c9 100644 --- a/clang/lib/Sema/SemaExprCXX.cpp +++ b/clang/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/clang/test/SemaCXX/type-traits.cpp b/clang/test/SemaCXX/type-traits.cpp index 28fb8dc749fd..3b94ef0951eb 100644 --- a/clang/test/SemaCXX/type-traits.cpp +++ b/clang/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() {