Article View: comp.std.c
Article #2859Re: Interpretation of peculiar declarators?
From: Norman Diamond
Date: Wed, 08 May 1991 00:05
Date: Wed, 08 May 1991 00:05
35 lines
2036 bytes
2036 bytes
In article <679@rosie.NeXT.COM> mself@next.com writes:
> typedef int t;
> void foo (void) { t t, x; }
>I believe this ought to declare t and x to be of type int,
I believe that the BNF constructions cause this result.
>An even more complicated case is this:
> t t = 1, x = t;
>In this case I believe that this is exactly equivalent to
> int t = 1, x = t;
>That is, it declares t and x to be of type int, and initializes x to the
>current value of t (which is 1).
This seems true too, for the reasons you gave (and I deleted).
>If all of this speculation is true, then it puts some fairly strong constraints
>on the implementation of compilers. A compiler must look up any type name in
>the type-specifier only once (before processing any of the declarators), and it
>must enter the newly declared identifiers into the symbol table before
>processing subsequent declarators.
Sorry to be pedantic, but the compiler only has to behave "as if" it were
doing this. Out of curiosity, what else would you want to do? Would you
prefer for the result to be undefined? Maybe this causes a bit of extra
work in implementing an incremental compiler, but surely there is no other
meaningful result.
>Can anyone clear this up?
I'd say you cleared this up yourself, mself.
--
Norman Diamond diamond@tkov50.enet.dec.com
If this were the company's opinion, I wouldn't be allowed to post it.
Technical Details
Message-ID:
<1991May8.000545.16590@tkou02.enet.dec.com>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!elroy.jpl.nasa.gov!sdd.hp.com!decwrl!pa.dec.com!jrdzzz.jrd.dec.com!tkou02.enet.dec.com!jit533!diamondReferences:
<679@rosie.NeXT.COM>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!elroy.jpl.nasa.gov!sdd.hp.com!decwrl!pa.dec.com!jrdzzz.jrd.dec.com!tkou02.enet.dec.com!jit533!diamond From: diamond@jit533.swstokyo.dec.com (Norman Diamond) Newsgroups: comp.std.c Subject: Re: Interpretation of peculiar declarators? Message-ID: <1991May8.000545.16590@tkou02.enet.dec.com> Date: 8 May 91 00:05:45 GMT References: <679@rosie.NeXT.COM> Sender: usenet@tkou02.enet.dec.com (USENET News System) Reply-To: diamond@jit533.enet@tkou02.enet.dec.com (Norman Diamond) Organization: Digital Equipment Corporation Japan , Tokyo Lines: 35