From 6a9bd957cb888a3fe3b6d9359f31dd1408ba469b Mon Sep 17 00:00:00 2001 From: Orgad Shaneh Date: Fri, 24 Apr 2015 09:29:27 +0300 Subject: [PATCH] C++: Fix instantiation of typedefed type in block Use-case: template struct Temp { T t; }; struct Foo { int bar; }; void func() { typedef Foo *pointer; Temp temp; temp.t->bar; // bar not highlighted } Task-number: QTCREATORBUG-14351 Change-Id: I13ca6145a0069bbc7a7207f69b43011c69ec72c7 Reviewed-by: Nikolai Kosjar --- src/libs/cplusplus/LookupContext.cpp | 5 +---- tests/auto/cplusplus/checksymbols/tst_checksymbols.cpp | 1 - 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/libs/cplusplus/LookupContext.cpp b/src/libs/cplusplus/LookupContext.cpp index 93b576ffc7d..7dd409a5cc8 100644 --- a/src/libs/cplusplus/LookupContext.cpp +++ b/src/libs/cplusplus/LookupContext.cpp @@ -993,7 +993,7 @@ LookupScope *LookupScope::lookupType(const Name *name, Block *block) = nestedBlock->d->lookupType_helper(name, &processed, /*searchInEnclosingScope = */ true, - d)) { + nestedBlock->d)) { return foundInNestedBlock; } } @@ -1339,9 +1339,6 @@ LookupScopePrivate *LookupScopePrivate::nestedType(const Name *name, LookupScope _alreadyConsideredTemplates.insert(templId); LookupScopePrivate *instantiation = baseTemplateClassReference->allocateChild(templId); - while (!origin->_symbols.isEmpty() && origin->_symbols[0]->isBlock()) - origin = origin->_parent; - instantiation->_instantiationOrigin = origin; // The instantiation should have all symbols, enums, and usings from the reference. diff --git a/tests/auto/cplusplus/checksymbols/tst_checksymbols.cpp b/tests/auto/cplusplus/checksymbols/tst_checksymbols.cpp index 012fc1310b9..98dc98504fc 100644 --- a/tests/auto/cplusplus/checksymbols/tst_checksymbols.cpp +++ b/tests/auto/cplusplus/checksymbols/tst_checksymbols.cpp @@ -1204,7 +1204,6 @@ void tst_CheckSymbols::findField() Use use = tc.findUse(line, column); QEXPECT_FAIL("pointer_indirect_specialization_typedef", "QTCREATORBUG-14141", Abort); QEXPECT_FAIL("pointer_indirect_specialization_double_indirection", "QTCREATORBUG-14141", Abort); - QEXPECT_FAIL("instantiation_of_pointer_typedef_in_block", "QTCREATORBUG-14141", Abort); QEXPECT_FAIL("pointer_indirect_specialization_double_indirection_with_base", "QTCREATORBUG-14141", Abort); QEXPECT_FAIL("recursive_instantiation_of_template_type", "QTCREATORBUG-14237", Abort); QVERIFY(use.isValid());