[Prev][Next][Index]

C++ operator parser bug




Consider the following code:

	class Y {
	  public: int operator[]( int );
	};
	
	int Y::operator[]( int a ) {}
	
	class X {
	  public: Y operator[]( int );
	};
	
	Y X::operator[]( int a ) {}
	
	void main() {
	  X x; 
	  x[5][7];
	}

The parser gets the array subscripting expression in main() wrong. It
_should_ be parsed as

	(x.operator[](5)).operator[](7)

but is instead parsed simply as

	x[5][7]

i.e., as if x were an array. If one does some explicit grouping here:

	(x[5])[7]

one gets a partially correct result, namely

	(x[5]).operator[](7)

but this is still not right, as x is not an array.

I am working on the call graph analyzer and getting operators right w/o
special casing this would be nice, although I know how I'd do it. Any chance
of getting a fix (or pointers to a fix) soon?

Thanks,

--lars