This revision was automatically updated to reflect the committed changes. Closed by commit rG21ff345d64b9: [Sema][C++1z] Ensure binding in dependent range for have non-null type (authored by erik.pilkington). Herald added subscribers: ributzka, dexonsmith, jkorous. Herald added a project: clang.
Changed prior to commit: https://reviews.llvm.org/D34096?vs=102191&id=223537#toc Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D34096/new/ https://reviews.llvm.org/D34096 Files: clang/lib/Sema/SemaStmt.cpp clang/test/SemaCXX/cxx1z-decomposition.cpp Index: clang/test/SemaCXX/cxx1z-decomposition.cpp =================================================================== --- clang/test/SemaCXX/cxx1z-decomposition.cpp +++ clang/test/SemaCXX/cxx1z-decomposition.cpp @@ -70,4 +70,10 @@ return foobar_; // expected-error {{undeclared identifier 'foobar_'}} } +// PR32172 +template <class T> void dependent_foreach(T t) { + for (auto [a,b,c] : t) + a,b,c; +} + // FIXME: by-value array copies Index: clang/lib/Sema/SemaStmt.cpp =================================================================== --- clang/lib/Sema/SemaStmt.cpp +++ clang/lib/Sema/SemaStmt.cpp @@ -2206,8 +2206,12 @@ // Deduce any 'auto's in the loop variable as 'DependentTy'. We'll fill // them in properly when we instantiate the loop. - if (!LoopVar->isInvalidDecl() && Kind != BFRK_Check) + if (!LoopVar->isInvalidDecl() && Kind != BFRK_Check) { + if (auto *DD = dyn_cast<DecompositionDecl>(LoopVar)) + for (auto *Binding : DD->bindings()) + Binding->setType(Context.DependentTy); LoopVar->setType(SubstAutoType(LoopVar->getType(), Context.DependentTy)); + } } else if (!BeginDeclStmt.get()) { SourceLocation RangeLoc = RangeVar->getLocation();
Index: clang/test/SemaCXX/cxx1z-decomposition.cpp =================================================================== --- clang/test/SemaCXX/cxx1z-decomposition.cpp +++ clang/test/SemaCXX/cxx1z-decomposition.cpp @@ -70,4 +70,10 @@ return foobar_; // expected-error {{undeclared identifier 'foobar_'}} } +// PR32172 +template <class T> void dependent_foreach(T t) { + for (auto [a,b,c] : t) + a,b,c; +} + // FIXME: by-value array copies Index: clang/lib/Sema/SemaStmt.cpp =================================================================== --- clang/lib/Sema/SemaStmt.cpp +++ clang/lib/Sema/SemaStmt.cpp @@ -2206,8 +2206,12 @@ // Deduce any 'auto's in the loop variable as 'DependentTy'. We'll fill // them in properly when we instantiate the loop. - if (!LoopVar->isInvalidDecl() && Kind != BFRK_Check) + if (!LoopVar->isInvalidDecl() && Kind != BFRK_Check) { + if (auto *DD = dyn_cast<DecompositionDecl>(LoopVar)) + for (auto *Binding : DD->bindings()) + Binding->setType(Context.DependentTy); LoopVar->setType(SubstAutoType(LoopVar->getType(), Context.DependentTy)); + } } else if (!BeginDeclStmt.get()) { SourceLocation RangeLoc = RangeVar->getLocation();
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits