Skip to content

Commit e3da53b

Browse files
author
andreasfertig
authored
Merge pull request andreasfertig#21 from andreasfertig/fixedIssue20
Fixed andreasfertig#20: DecompositionDecl with CXXOperatorCallExpr
2 parents 5ccd388 + f10b15c commit e3da53b

File tree

4 files changed

+25
-0
lines changed

4 files changed

+25
-0
lines changed

ClassOperatorHandler.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ ClassOperatorHandler::ClassOperatorHandler(Rewriter& rewrite, MatchFinder& match
4545
hasLambdaAncestor,
4646
hasAncestor(implicitCastExpr(hasMatchingCast())),
4747
hasAncestor(userDefinedLiteral()),
48+
hasAncestor(decompositionDecl()),
4849
hasAncestor(cxxForRangeStmt())
4950
#ifdef MATCH_CXX_MEM_CEXPR
5051
,

tests/Issue20.cerr

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.tmp.cpp:7:63: error: rvalue reference to type 'std::tuple_element<0, std::pair<const int, int> >::type' (aka 'const int') cannot bind to lvalue of type 'typename tuple_element<0UL, pair<const int, int> >::type' (aka 'const int')
2+
std::tuple_element<0, std::pair<const int, int> >::type&& key = std::get<0ul>(__operator6);
3+
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~
4+
.tmp.cpp:8:63: error: rvalue reference to type 'std::tuple_element<1, std::pair<const int, int> >::type' (aka 'int') cannot bind to lvalue of type 'typename tuple_element<1UL, pair<const int, int> >::type' (aka 'int')
5+
std::tuple_element<1, std::pair<const int, int> >::type&& value = std::get<1ul>(__operator6);
6+
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~
7+
2 errors generated.

tests/Issue20.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#include <map>
2+
3+
int main()
4+
{
5+
std::map<int, int> map{{1, 2}};
6+
auto [key, value] = *map.begin();
7+
}

tests/Issue20.expect

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#include <map>
2+
3+
int main()
4+
{
5+
std::map<int, int> map{ std::initializer_list<std::pair<const int, int> >{ std::pair<const int, int>(1, 2) } };
6+
std::pair<const int, int> __operator6 = std::pair<const int, int>(map.begin().operator*());
7+
std::tuple_element<0, std::pair<const int, int> >::type&& key = std::get<0ul>(__operator6);
8+
std::tuple_element<1, std::pair<const int, int> >::type&& value = std::get<1ul>(__operator6);
9+
10+
}

0 commit comments

Comments
 (0)