r338478 - Work around GCC miscompile exposed by r338464.
Richard Smith via cfe-commits
cfe-commits at lists.llvm.org
Tue Jul 31 19:27:18 PDT 2018
Author: rsmith
Date: Tue Jul 31 19:27:18 2018
New Revision: 338478
URL: http://llvm.org/viewvc/llvm-project?rev=338478&view=rev
Log:
Work around GCC miscompile exposed by r338464.
See gcc.gnu.org/PR86769 for details of the bug.
Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=338478&r1=338477&r2=338478&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Jul 31 19:27:18 2018
@@ -6011,9 +6011,12 @@ static void checkAttributesAfterMerging(
// Check the attributes on the function type, if any.
if (const auto *FD = dyn_cast<FunctionDecl>(&ND)) {
+ // Don't declare this variable in the second operand of the for-statement;
+ // GCC miscompiles that by ending its lifetime before evaluating the
+ // third operand. See gcc.gnu.org/PR86769.
+ AttributedTypeLoc ATL;
for (TypeLoc TL = FD->getTypeSourceInfo()->getTypeLoc();
- auto ATL = TL ? TL.getAsAdjusted<AttributedTypeLoc>()
- : AttributedTypeLoc();
+ (ATL = TL.getAsAdjusted<AttributedTypeLoc>());
TL = ATL.getModifiedLoc()) {
// The [[lifetimebound]] attribute can be applied to the implicit object
// parameter of a non-static member function (other than a ctor or dtor)
More information about the cfe-commits
mailing list