mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Bug 332883: Auto type for range based for loop.
This commit is contained in:
parent
9e7125fb90
commit
35a66ea763
2 changed files with 28 additions and 1 deletions
|
@ -9367,6 +9367,33 @@ public class AST2CPPTests extends AST2BaseTest {
|
|||
parseAndCheckBindings();
|
||||
}
|
||||
|
||||
// namespace std {
|
||||
// template <class T1, class T2> struct pair {
|
||||
// T1 first;
|
||||
// T2 second;
|
||||
// };
|
||||
//
|
||||
// template <typename T, typename U> T begin(const pair<T, U>& p) {
|
||||
// return p.first;
|
||||
// }
|
||||
// template <typename T, typename U> U end(const pair<T, U>& p) {
|
||||
// return p.second;
|
||||
// }
|
||||
// }
|
||||
// struct S {
|
||||
// int x;
|
||||
// };
|
||||
//
|
||||
// int main() {
|
||||
// S arr[5];
|
||||
// std::pair<S*, S*> p{arr, arr + 5};
|
||||
// for (const auto& r : p)
|
||||
// r.x;
|
||||
// }
|
||||
public void testAutoTypeInRangeBasedFor_332883c() throws Exception {
|
||||
parseAndCheckBindings();
|
||||
}
|
||||
|
||||
// struct S {
|
||||
// void f();
|
||||
// };
|
||||
|
|
|
@ -1927,7 +1927,7 @@ public class CPPVisitor extends ASTQueries {
|
|||
beginExpr= expr.copy();
|
||||
} else if (type instanceof ICPPClassType) {
|
||||
ICPPClassType ct= (ICPPClassType) type;
|
||||
if (ct.getCompositeScope().find(BEGIN_STR).length > 0) {
|
||||
if (CPPSemantics.findBindings(ct.getCompositeScope(), BEGIN_STR, true).length > 0) {
|
||||
final CPPASTName name = new CPPASTName(BEGIN);
|
||||
name.setOffset(((ASTNode) forInit).getOffset());
|
||||
beginExpr= new CPPASTFunctionCallExpression(
|
||||
|
|
Loading…
Add table
Reference in a new issue