]> granicus.if.org Git - clang/commit
Merging r352323:
authorHans Wennborg <hans@hanshq.net>
Mon, 28 Jan 2019 13:47:09 +0000 (13:47 +0000)
committerHans Wennborg <hans@hanshq.net>
Mon, 28 Jan 2019 13:47:09 +0000 (13:47 +0000)
commite6bf555407449327770d55daef14b6699c343a0b
tree029c8f9e006876eb5eaf05bc8246766f5a240664
parent4d37fec6c9b50397feff988fb8cab7749a916454
Merging r352323:
Redirecting to URL 'https://llvm.org/svn/llvm-project/cfe/trunk':
------------------------------------------------------------------------
r352323 | rakete1111 | 2019-01-27 20:19:59 +0100 (Sun, 27 Jan 2019) | 31 lines

[SemaCXX] Fix ICE with structure bindings to members of template

Summary:
Trying to use structure binding with a structure that doesn't implement
std::tuple_size, should unpack the data members. When the struct is a
template though, clang might hit an assertion (if the type has not been
completed before), because CXXRecordDecl::DefinitionData is nullptr.

This commit fixes the problem by completing the type while trying to
decompose the structured binding.

The ICE happens in real world code, for example, when trying to iterate
a protobuf generated map with a range-based for loop and structure
bindings (because google::protobuf::MapPair is a template and doesn't
support std::tuple_size).

Reported-by: nicholas.sun@nlsun.com
Patch by Daniele Di Proietto

Reviewers: #clang, rsmith

Reviewed By: #clang, rsmith

Subscribers: cpplearner, Rakete1111, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D56974

------------------------------------------------------------------------

git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_80@352356 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Sema/SemaDeclCXX.cpp
test/SemaCXX/cxx1z-decomposition.cpp