1
0
Fork 0
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:
Markus Schorn 2011-12-21 18:03:31 +01:00
parent 9e7125fb90
commit 35a66ea763
2 changed files with 28 additions and 1 deletions

View file

@ -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();
// };

View file

@ -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(