Mangling: grammar too permissive

Jim Dehnert dehnert at baalbek.engr.sgi.com
Tue Mar 28 03:37:43 UTC 2000


> From: Martin von Loewis <loewis at informatik.hu-berlin.de>
> 
> After reviewing today's mangling grammar, I found that it allows a
> number of constructions that can't possibly appear, and that can be
> easily correct in the grammar:
> 
> 1. <substitution> in <qualified name>: This allows <nested-names> of
>    NSi_E, where i is either a letter or a (base-36) digit. I think
>    this cannot, or should not, occur: If you can substitute the entire
>    <qualified-name>, you should use Si_ instead.
> 
>    Solution: Remove <substitution> alternative in <qualified name>

No, it's needed to be able to substitute for Ktype when we've
already seen VKtype.

> 2. extra alternatives in <encoding-type>: In all cases where an
>    encoding-type can occur, it always identifies a
>    bare-function-type; it never is a type or a substitution on its
>    own. Therefore, I propose to remove the encoding-type, and replace
>    its two occurences with bare-function-type.

No, <encoding-type> also encodes a <type> in the case of a vtable,
where <name> is the <special-name> VT, and <type> is the relevant class
type.  (Though this could probably be fixed by other rearrangements.)

> 3. extern "C" allowed at toplevel. The grammar allows _Z3fooYi, which
>    would be extern "C" ??? foo(int). However (as the text points out),
>    that would be mangled as "foo", so it cannot happen.
>    Solution: Move [Y] from <bare-function-type> into <function-type>.

OK, I did that.

Jim

-	    Jim Dehnert		dehnert at sgi.com
				(650)933-4272




More information about the cxx-abi-dev mailing list