@@ -4084,26 +4084,27 @@ static bool evaluateTypeTrait(Sema &S, TypeTrait Kind, SourceLocation KWLoc,
40844084 return false ;
40854085 }
40864086
4087- // Make sure the first argument is a complete type.
4088- if (Args[0 ]->getType ()->isIncompleteType ())
4087+ // Make sure the first argument is not incomplete nor a function type.
4088+ QualType T = Args[0 ]->getType ();
4089+ if (T->isIncompleteType () || T->isFunctionType ())
40894090 return false ;
40904091
40914092 // Make sure the first argument is not an abstract type.
4092- CXXRecordDecl *RD = Args[ 0 ]-> getType () ->getAsCXXRecordDecl ();
4093+ CXXRecordDecl *RD = T ->getAsCXXRecordDecl ();
40934094 if (RD && RD->isAbstract ())
40944095 return false ;
40954096
40964097 SmallVector<OpaqueValueExpr, 2 > OpaqueArgExprs;
40974098 SmallVector<Expr *, 2 > ArgExprs;
40984099 ArgExprs.reserve (Args.size () - 1 );
40994100 for (unsigned I = 1 , N = Args.size (); I != N; ++I) {
4100- QualType T = Args[I]->getType ();
4101- if (T ->isObjectType () || T ->isFunctionType ())
4102- T = S.Context .getRValueReferenceType (T );
4101+ QualType ArgTy = Args[I]->getType ();
4102+ if (ArgTy ->isObjectType () || ArgTy ->isFunctionType ())
4103+ ArgTy = S.Context .getRValueReferenceType (ArgTy );
41034104 OpaqueArgExprs.push_back (
4104- OpaqueValueExpr (Args[I]->getTypeLoc ().getLocStart (),
4105- T .getNonLValueExprType (S.Context ),
4106- Expr::getValueKindForType (T )));
4105+ OpaqueValueExpr (Args[I]->getTypeLoc ().getLocStart (),
4106+ ArgTy .getNonLValueExprType (S.Context ),
4107+ Expr::getValueKindForType (ArgTy )));
41074108 }
41084109 for (Expr &E : OpaqueArgExprs)
41094110 ArgExprs.push_back (&E);
@@ -4134,7 +4135,7 @@ static bool evaluateTypeTrait(Sema &S, TypeTrait Kind, SourceLocation KWLoc,
41344135 // Under Objective-C ARC, if the destination has non-trivial Objective-C
41354136 // lifetime, this is a non-trivial construction.
41364137 if (S.getLangOpts ().ObjCAutoRefCount &&
4137- hasNontrivialObjCLifetime (Args[ 0 ]-> getType () .getNonReferenceType ()))
4138+ hasNontrivialObjCLifetime (T .getNonReferenceType ()))
41384139 return false ;
41394140
41404141 // The initialization succeeded; now make sure there are no non-trivial
0 commit comments