[Prev][Next][Index]

more scoping trouble




[Note: I have not yet fetched the latest fixes from Beata, so the
following problem _may_ have been fixed. However, it is sufficiently
different from earlier ones that I doubt it.]

Consider the file bug8.pc:

	struct ss { int xyzzy; };

	main()
	{
	  int foo;
	  if (foo) {
	    static ss *bar;
	    bar->xyzzy = 1;
	  }
	  else {
	    struct ss bar;
	    bar.xyzzy = 1;
	  }
	}

Compiling this, I get the error message:

	earth(16) % pc++ bug8.pc
	Error on line 11 of bug8.pc:symbol 'bar'  (03) redeclaration symbol
	Error in pc++ while executing:
	------->  pC++2dep  TEMP_pC++.C

That is, on the second declaration of 'bar'. Curiously, this works when
there is not an if-else, but only two scopes after each other:

	{ static ss*bar; }
	{ stuct ss bar; }

Looks like the IF-parsing is a little aggressive in terms of scope
flattening (or something to that effect).

Happy weekend,
--lars