[cfe-commits] r64153 - in /cfe/trunk: include/clang/AST/ASTContext.h include/clang/AST/DeclTemplate.h include/clang/AST/Type.h include/clang/Parse/Action.h include/clang/Parse/Parser.h lib/AST/ASTContext.cpp lib/AST/DeclTemplate.cpp lib/AST/Type.cpp lib/AST/TypeSerialization.cpp lib/CodeGen/CodeGenTypes.cpp lib/Parse/MinimalAction.cpp lib/Parse/ParseDecl.cpp lib/Parse/ParseExpr.cpp lib/Parse/ParseTemplate.cpp lib/Parse/Parser.cpp lib/Sema/Sema.h lib/Sema/SemaTemplate.cpp test/SemaTemplate/class-template-id.cpp

Douglas Gregor dgregor at apple.com
Tue Feb 10 17:06:17 PST 2009


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20090210/003ebf89/attachment.html>


More information about the cfe-commits mailing list