On Feb 10, 2009, at 4:59 PM, Chris Lattner wrote:


On Feb 9, 2009, at 12:58 PM, Douglas Gregor wrote:


On Feb 9, 2009, at 12:05 PM, Sebastian Redl wrote:

Douglas Gregor wrote:
Author: dgregor
Date: Mon Feb  9 12:46:07 2009
New Revision: 64153

URL: http://llvm.org/viewvc/llvm-project?rev=64153&view=rev
Log:
Start processing template-ids as types when the template-name refers
to a class template. For example, the template-id 'vector<int>' now
has a nice, sugary type in the type system. What we can do now:

- Parse template-ids like 'vector<int>' (where 'vector' names a
class template) and form proper types for them in the type system.
- Parse icky template-ids like 'A<5>' and 'A<(5 > 0)>' properly,
  using (sadly) a bool in the parser to tell it whether '>' should
  be treated as an operator or not.

I suppose it can't be helped.

The only other option I can think of would be to pass it as a boolean
flag down the stack... that's almost worse :)

Naive question: is this just a matter of parsing the expression starting at the right precedence level?

Sadly, no; other operations at that same precedence level (<, <=, >=) can still show up. For example,

        A< 5 < 0> *a;

is well-formed.

Plus, in C++0x, '>>' can also terminate a template-argument-list or a default template argument. (And there's some fancy footwork to be done to recover from "vector<vector<int>>" in C++98 mode).

        - Doug
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to