diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2018-08-01 02:27:18 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2018-08-01 02:27:18 +0000 |
commit | 1dd9501b3a455be649bc5af484f62433753e75cf (patch) | |
tree | 61a20586273818d945e5cecfb8a4b4712bbc4761 /clang/lib/Sema | |
parent | 5c63af0d040a377c4fe13a75dea5bb6f84116b9e (diff) | |
download | bcm5719-llvm-1dd9501b3a455be649bc5af484f62433753e75cf.tar.gz bcm5719-llvm-1dd9501b3a455be649bc5af484f62433753e75cf.zip |
Work around GCC miscompile exposed by r338464.
See gcc.gnu.org/PR86769 for details of the bug.
llvm-svn: 338478
Diffstat (limited to 'clang/lib/Sema')
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index eb76b949af8..b92d76ad420 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -6011,9 +6011,12 @@ static void checkAttributesAfterMerging(Sema &S, NamedDecl &ND) { // 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) |