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:
Christian Kandeler
2020-11-03 14:25:46 +01:00
parent 53115259ba
commit 882dd60aad
2 changed files with 18 additions and 3 deletions

View File

@@ -1527,10 +1527,23 @@ bool Parser::parseDeclSpecifierSeq(SpecifierListAST *&decl_specifier_seq,
} else if (! onlySimpleTypeSpecifiers && ! has_type_specifier &&
(LA() == T_TYPENAME || LA() == T_ENUM || lookAtClassKey())) {
// typename-specifier, elaborated-type-specifier
int startOfElaboratedTypeSpecifier = cursor();
int startOfTypeSpecifier = cursor();
if (! parseElaboratedTypeSpecifier(*decl_specifier_seq_ptr)) {
error(startOfElaboratedTypeSpecifier, "expected an elaborated type specifier");
break;
rewind(startOfTypeSpecifier);
if (LA() == T_ENUM) {
if (!parseEnumSpecifier(*decl_specifier_seq_ptr)) {
error(startOfTypeSpecifier, "expected an enum specifier");
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;
has_type_specifier = true;

View File

@@ -2,3 +2,5 @@ using Foo = int;
using Bar = std::vector<int>::value_type;
using A [[foo]] = const float;
using B alignas(void*) = C *;
using C = struct {};
using D = enum class E {A, B};