forked from qt-creator/qt-creator
C++: Extend alias declaration support in built-in parser
The type-id in an alias declaration can also define a new type. Change-Id: I65dc397d2526c56334676c6ab522564f6748d594 Task-number: QTCREATORBUG-24875 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
17
src/libs/3rdparty/cplusplus/Parser.cpp
vendored
17
src/libs/3rdparty/cplusplus/Parser.cpp
vendored
@@ -1527,11 +1527,24 @@ bool Parser::parseDeclSpecifierSeq(SpecifierListAST *&decl_specifier_seq,
|
|||||||
} else if (! onlySimpleTypeSpecifiers && ! has_type_specifier &&
|
} else if (! onlySimpleTypeSpecifiers && ! has_type_specifier &&
|
||||||
(LA() == T_TYPENAME || LA() == T_ENUM || lookAtClassKey())) {
|
(LA() == T_TYPENAME || LA() == T_ENUM || lookAtClassKey())) {
|
||||||
// typename-specifier, elaborated-type-specifier
|
// typename-specifier, elaborated-type-specifier
|
||||||
int startOfElaboratedTypeSpecifier = cursor();
|
int startOfTypeSpecifier = cursor();
|
||||||
if (! parseElaboratedTypeSpecifier(*decl_specifier_seq_ptr)) {
|
if (! parseElaboratedTypeSpecifier(*decl_specifier_seq_ptr)) {
|
||||||
error(startOfElaboratedTypeSpecifier, "expected an elaborated type specifier");
|
rewind(startOfTypeSpecifier);
|
||||||
|
if (LA() == T_ENUM) {
|
||||||
|
if (!parseEnumSpecifier(*decl_specifier_seq_ptr)) {
|
||||||
|
error(startOfTypeSpecifier, "expected an enum specifier");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
} else if (lookAtClassKey()) {
|
||||||
|
if (!parseClassSpecifier(*decl_specifier_seq_ptr)) {
|
||||||
|
error(startOfTypeSpecifier, "expected a class specifier");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
error(startOfTypeSpecifier, "expected an elaborated type specifier");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
decl_specifier_seq_ptr = &(*decl_specifier_seq_ptr)->next;
|
decl_specifier_seq_ptr = &(*decl_specifier_seq_ptr)->next;
|
||||||
has_type_specifier = true;
|
has_type_specifier = true;
|
||||||
} else
|
} else
|
||||||
|
@@ -2,3 +2,5 @@ using Foo = int;
|
|||||||
using Bar = std::vector<int>::value_type;
|
using Bar = std::vector<int>::value_type;
|
||||||
using A [[foo]] = const float;
|
using A [[foo]] = const float;
|
||||||
using B alignas(void*) = C *;
|
using B alignas(void*) = C *;
|
||||||
|
using C = struct {};
|
||||||
|
using D = enum class E {A, B};
|
||||||
|
Reference in New Issue
Block a user