diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/libs/cplusplus/ResolveExpression.cpp | 8 | ||||
| -rw-r--r-- | src/plugins/cpptools/cppcompletion_test.cpp | 13 |
2 files changed, 19 insertions, 2 deletions
diff --git a/src/libs/cplusplus/ResolveExpression.cpp b/src/libs/cplusplus/ResolveExpression.cpp index 9470efc2b4c..ffdaaf5b106 100644 --- a/src/libs/cplusplus/ResolveExpression.cpp +++ b/src/libs/cplusplus/ResolveExpression.cpp @@ -866,8 +866,12 @@ ClassOrNamespace *ResolveExpression::findClass(const FullySpecifiedType &origina FullySpecifiedType ty = originalTy.simplified(); ClassOrNamespace *binding = 0; - if (Class *klass = ty->asClassType()) - binding = _context.lookupType(klass, enclosingTemplateInstantiation); + if (Class *klass = ty->asClassType()) { + if (scope->isBlock()) + binding = _context.lookupType(klass->name(), scope, enclosingTemplateInstantiation); + if (!binding) + binding = _context.lookupType(klass, enclosingTemplateInstantiation); + } else if (NamedType *namedTy = ty->asNamedType()) binding = _context.lookupType(namedTy->name(), scope, enclosingTemplateInstantiation); diff --git a/src/plugins/cpptools/cppcompletion_test.cpp b/src/plugins/cpptools/cppcompletion_test.cpp index 742e0a99eee..bf8fb0f772c 100644 --- a/src/plugins/cpptools/cppcompletion_test.cpp +++ b/src/plugins/cpptools/cppcompletion_test.cpp @@ -1441,6 +1441,19 @@ void CppToolsPlugin::test_completion_data() << QLatin1String("A") << QLatin1String("a")); + QTest::newRow("nested_class_declaration_with_object_name_inside_function") << _( + "int foo()\n" + "{\n" + " struct Nested\n" + " {\n" + " int i;\n" + " } n;\n" + " @;\n" + "}\n" + ) << _("n.") << (QStringList() + << QLatin1String("Nested") + << QLatin1String("i")); + QTest::newRow("nested_anonymous_class_QTCREATORBUG10876_1") << _( "struct EnclosingStruct\n" "{\n" |
