This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Canonical type nodes, or, comptypes considered harmful


"Doug Gregor" <doug.gregor@gmail.com> writes:

[...]

| With concepts, there are cases where we end up creating two different
| type nodes that we later find out should have been the same type node.
| Here's an example:
| 
|   template<typename T, typename U>
|   where LessThanComparable<T> && SameType<T, U>
|   const T& weird_min(const T& t, const U& u) {
|     return t < u? t : u;
|   }
| 
| When we parse the template header, we create two different type nodes
| for T and U. Then we start parsing the where clause, and create a type
| node for LessThanComparable<T>. Now we hit the SameType requirement,
| which says that T and U are the same type. It's a little late to make
| T and U actually have the same type node (unless we want to re-parse
| the template or re-write the AST).

I don't think that implies rewriting the AST or reparsing.  The
same-type constraints reads to me that "it is assume T and U have the
same canonical type", e.g. the predicate SameType<T, U> translates to
the constraints

     TYPE_CANONICAL(T) == TYPE_CANONICAL(U)

this equation can be added the constraint set without reparsing (it is
a semantic constraint).

-- Gaby


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]