From: Iain Buclaw Date: Mon, 1 May 2017 10:45:35 +0000 (+0000) Subject: d-demangle.c (dlang_identifier): Handle template constraint symbols. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c6f44bae7e0a338b533e541c8e369b920ffe83f0;p=gcc.git d-demangle.c (dlang_identifier): Handle template constraint symbols. libiberty/ChangeLog: * d-demangle.c (dlang_identifier): Handle template constraint symbols. (dlang_parse_template): Only advance if template symbol prefix is followed by a digit. * testsuite/d-demangle-expected: Add tests. From-SVN: r247433 --- diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog index d4c054ffe83..7aa4821d610 100644 --- a/libiberty/ChangeLog +++ b/libiberty/ChangeLog @@ -1,3 +1,10 @@ +2017-04-15 Iain Buclaw + + * d-demangle.c (dlang_identifier): Handle template constraint symbols. + (dlang_parse_template): Only advance if template symbol prefix is + followed by a digit. + * testsuite/d-demangle-expected: Add tests. + 2017-05-01 Iain Buclaw * d-demangle.c (dlang_attributes): Handle scope attributes. diff --git a/libiberty/d-demangle.c b/libiberty/d-demangle.c index af7c63d1086..74dde9d9b0c 100644 --- a/libiberty/d-demangle.c +++ b/libiberty/d-demangle.c @@ -769,14 +769,9 @@ dlang_identifier (string *decl, const char *mangled, mangled = endptr; /* May be a template instance. */ - if (len >= 5 && strncmp (mangled, "__T", 3) == 0) - { - /* Template symbol. */ - if (ISDIGIT (mangled[3]) && mangled[3] != '0') - return dlang_parse_template (decl, mangled, len); - - return NULL; - } + if (len >= 5 && mangled[0] == '_' && mangled[1] == '_' + && (mangled[2] == 'T' || mangled[2] == 'U')) + return dlang_parse_template (decl, mangled, len); switch (len) { @@ -1541,11 +1536,14 @@ dlang_parse_template (string *decl, const char *mangled, long len) TemplateInstanceName: Number __T LName TemplateArgs Z + Number __U LName TemplateArgs Z ^ The start pointer should be at the above location, and LEN should be the value of the decoded number. */ - if (strncmp (mangled, "__T", 3) != 0) + + /* Template symbol. */ + if (!ISDIGIT (mangled[3]) || mangled[3] == '0') return NULL; mangled += 3; diff --git a/libiberty/testsuite/d-demangle-expected b/libiberty/testsuite/d-demangle-expected index 57f7c52331b..6725684ff33 100644 --- a/libiberty/testsuite/d-demangle-expected +++ b/libiberty/testsuite/d-demangle-expected @@ -650,6 +650,10 @@ _D8demangle9__T4testZv demangle.test!() # --format=dlang +_D8demangle9__U4testZv +demangle.test!() +# +--format=dlang _D8demangle11__T4testTaZv demangle.test!(char) #