Fixed in 320493. Thanks for catching that. From: Richard Smith [mailto:rich...@metafoo.co.uk] Sent: Tuesday, December 12, 2017 8:07 AM To: Keane, Erich <erich.ke...@intel.com> Cc: cfe-commits <cfe-commits@lists.llvm.org> Subject: Re: r320489 - Fix ICE when __has_unqiue_object_representations called with invalid decl
On 12 Dec 2017 16:02, "Erich Keane via cfe-commits" <cfe-commits@lists.llvm.org<mailto:cfe-commits@lists.llvm.org>> wrote: Author: erichkeane Date: Tue Dec 12 08:02:06 2017 New Revision: 320489 URL: http://llvm.org/viewvc/llvm-project?rev=320489&view=rev Log: Fix ICE when __has_unqiue_object_representations called with invalid decl Modified: cfe/trunk/lib/AST/ASTContext.cpp cfe/trunk/lib/Sema/SemaExprCXX.cpp cfe/trunk/test/SemaCXX/type-traits.cpp Modified: cfe/trunk/lib/AST/ASTContext.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=320489&r1=320488&r2=320489&view=diff ============================================================================== --- cfe/trunk/lib/AST/ASTContext.cpp (original) +++ cfe/trunk/lib/AST/ASTContext.cpp Tue Dec 12 08:02:06 2017 @@ -2279,6 +2279,9 @@ bool ASTContext::hasUniqueObjectRepresen if (Ty->isRecordType()) { const RecordDecl *Record = Ty->getAs<RecordType>()->getDecl(); + if (Record->isInvalidDecl()) + return false; + if (Record->isUnion()) return unionHasUniqueObjectRepresentations(*this, Record); Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=320489&r1=320488&r2=320489&view=diff ============================================================================== --- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original) +++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Tue Dec 12 08:02:06 2017 @@ -4958,7 +4958,7 @@ static bool EvaluateBinaryTypeTrait(Sema EnterExpressionEvaluationContext Unevaluated( Self, Sema::ExpressionEvaluationContext::Unevaluated); Sema::SFINAETrap SFINAE(Self, /*AccessCheckingSFINAE=*/true); - Sema::ContextRAII TUContext(Self, Self.Context.getTranslationUnitDecl()); + Sema::ContextRAII TUContext(Self, Self.Context.getTranslationUnitDecl()); { ExprResult Result = Self.BuildBinOp(/*S=*/nullptr, KeyLoc, BO_Assign, &Lhs, &Rhs); if (Result.isInvalid() || SFINAE.hasErrorOccurred()) @@ -4981,6 +4981,7 @@ static bool EvaluateBinaryTypeTrait(Sema llvm_unreachable("unhandled type trait"); return false; + } Was this change intentional? } default: llvm_unreachable("not a BTT"); } Modified: cfe/trunk/test/SemaCXX/type-traits.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/type-traits.cpp?rev=320489&r1=320488&r2=320489&view=diff ============================================================================== --- cfe/trunk/test/SemaCXX/type-traits.cpp (original) +++ cfe/trunk/test/SemaCXX/type-traits.cpp Tue Dec 12 08:02:06 2017 @@ -2661,3 +2661,11 @@ static_assert(sizeof(CanBeUniqueIfNoPadd has_unique_object_representations<CanBeUniqueIfNoPadding>::value, "inherit from std layout"); +namespace ErrorType { + struct S; //expected-note{{forward declaration of 'ErrorType::S'}} + + struct T { + S t; //expected-error{{field has incomplete type 'ErrorType::S'}} + }; + bool b = __has_unique_object_representations(T); +}; _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org<mailto:cfe-commits@lists.llvm.org> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits