summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Storsjo <martin@martin.st>2018-08-02 18:12:08 +0000
committerMartin Storsjo <martin@martin.st>2018-08-02 18:12:08 +0000
commitd03fa9903f054de2c55e82012c9bdf198a17cbc8 (patch)
treefe5ad5ac2037d5e16dbd6e7a2fbb601b5a565c4a
parenta9cb2dd8b0d5be357e7aaf2b1a16f63eb703cdf8 (diff)
downloadbcm5719-llvm-d03fa9903f054de2c55e82012c9bdf198a17cbc8.tar.gz
bcm5719-llvm-d03fa9903f054de2c55e82012c9bdf198a17cbc8.zip
Work around more GCC miscompiles exposed by r338464.
This is the same fix as in r338478, for another occurrance of the same pattern from r338464. See gcc.gnu.org/PR86769 for details of the bug. llvm-svn: 338749
-rw-r--r--clang/lib/Sema/SemaInit.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp
index f006a677b67..01ef86c656b 100644
--- a/clang/lib/Sema/SemaInit.cpp
+++ b/clang/lib/Sema/SemaInit.cpp
@@ -6371,8 +6371,12 @@ static bool implicitObjectParamIsLifetimeBound(const FunctionDecl *FD) {
const TypeSourceInfo *TSI = FD->getTypeSourceInfo();
if (!TSI)
return false;
+ // 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 = TSI->getTypeLoc();
- auto ATL = TL.getAsAdjusted<AttributedTypeLoc>();
+ (ATL = TL.getAsAdjusted<AttributedTypeLoc>());
TL = ATL.getModifiedLoc()) {
if (ATL.getAttrKind() == AttributedType::attr_lifetimebound)
return true;
OpenPOWER on IntegriCloud