diff options
author | Przemyslaw Gorszkowski <pgorszkowski@gmail.com> | 2014-06-05 09:05:41 +0200 |
---|---|---|
committer | Nikolai Kosjar <nikolai.kosjar@digia.com> | 2014-06-06 15:38:02 +0200 |
commit | b90452e309dfeb308fd9b82b4fce8f32588caeb4 (patch) | |
tree | d11fe02b3ba4dec3959822b08db494f9e9762a91 /src | |
parent | aae1abdaccb274bc5e88ca83b6da2c8330722955 (diff) |
C++: fix nested anonymous with __attribute__
Task-number: QTCREATORBUG-12345
Change-Id: Ib2316ebdc81393b38185b9cb659fb85b78753e7b
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
Reviewed-by: Eike Ziller <eike.ziller@digia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/libs/3rdparty/cplusplus/Parser.cpp | 12 | ||||
-rw-r--r-- | src/plugins/cpptools/cppcompletion_test.cpp | 14 |
2 files changed, 20 insertions, 6 deletions
diff --git a/src/libs/3rdparty/cplusplus/Parser.cpp b/src/libs/3rdparty/cplusplus/Parser.cpp index bf19628fd23..dfdc260f6e7 100644 --- a/src/libs/3rdparty/cplusplus/Parser.cpp +++ b/src/libs/3rdparty/cplusplus/Parser.cpp @@ -1988,12 +1988,6 @@ bool Parser::parseClassSpecifier(SpecifierListAST *&node) NameAST *name = 0; parseName(name); - if (! name && LA() == T_LBRACE && (LA(0) == T_CLASS || LA(0) == T_STRUCT || LA(0) == T_UNION || LA(0) == T_ENUM)) { - AnonymousNameAST *ast = new (_pool) AnonymousNameAST; - ast->class_token = classkey_token; - name = ast; - } - bool parsed = false; const bool previousInFunctionBody = _inFunctionBody; @@ -2010,6 +2004,12 @@ bool Parser::parseClassSpecifier(SpecifierListAST *&node) } if (LA() == T_COLON || LA() == T_LBRACE) { + if (!name) { + AnonymousNameAST *ast = new (_pool) AnonymousNameAST; + ast->class_token = classkey_token; + name = ast; + } + BaseSpecifierListAST *base_clause_list = 0; if (LA() == T_COLON) { diff --git a/src/plugins/cpptools/cppcompletion_test.cpp b/src/plugins/cpptools/cppcompletion_test.cpp index 8679d3120a1..0dde60e9f92 100644 --- a/src/plugins/cpptools/cppcompletion_test.cpp +++ b/src/plugins/cpptools/cppcompletion_test.cpp @@ -1856,6 +1856,20 @@ void CppToolsPlugin::test_completion_data() << QLatin1String("val2") << QLatin1String("val3")); + QTest::newRow("nested_anonymous_with___attribute__") << _( + "struct Enclosing\n" + "{\n" + " struct __attribute__((aligned(8)))\n" + " {\n" + " int i;\n" + " };\n" + "};\n" + "Enclosing e;\n" + "@\n" + ) << _("e.") << (QStringList() + << QLatin1String("Enclosing") + << QLatin1String("i")); + QTest::newRow("enum_inside_namespace") << _( "namespace Ns\n" "{\n" |