From bbd542fac7fd78d6cb2b7c53cf198c3c79b3047d Mon Sep 17 00:00:00 2001 From: acqn Date: Sun, 10 Dec 2023 17:01:54 +0800 Subject: [PATCH] Fixed missing diagnosis on extra identifiers in type names. --- src/cc65/declare.c | 3 +++ test/err/type-name-extra-identifier.c | 25 +++++++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 test/err/type-name-extra-identifier.c diff --git a/src/cc65/declare.c b/src/cc65/declare.c index 029e22069..076e94aa8 100644 --- a/src/cc65/declare.c +++ b/src/cc65/declare.c @@ -2080,6 +2080,9 @@ static void DirectDecl (DeclSpec* Spec, Declarator* D, declmode_t Mode) DirectDecl (Spec, D, Mode); ConsumeRParen (); } else if (CurTok.Tok == TOK_IDENT) { + if (Mode == DM_NO_IDENT) { + Error ("Unexpected identifier in type name"); + } strcpy (D->Ident, CurTok.Ident); NextToken (); } else { diff --git a/test/err/type-name-extra-identifier.c b/test/err/type-name-extra-identifier.c new file mode 100644 index 000000000..72de4778d --- /dev/null +++ b/test/err/type-name-extra-identifier.c @@ -0,0 +1,25 @@ +/* + Copyright 2023 The cc65 Authors + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/* + Test of type name with extra identifier +*/ + +int a = sizeof (int b);