Various improvements to function overload resolution.

Generalize the overload resolution code to be based on estimating a
  cost for various overload options and picking the one with the
  minimal cost.
Add a step that considers type conversions that are guaranteed to
  not lose information in function overload resolution.
Print better diagnostics when we can't find an unambiguous match.
This commit is contained in:
Matt Pharr
2011-10-16 20:46:56 -04:00
parent 209d093720
commit 39ed7e14b2
3 changed files with 250 additions and 66 deletions

View File

@@ -956,10 +956,16 @@ a given type are found, an error is issued.
* All parameter types match exactly.
* All parameter types match exactly, where any ``reference``-qualified
parameters are considered equivalent to their underlying type.
* Parameters match with only type conversions that don't risk losing any
information (for example, converting an ``int16`` value to an ``int32``
parameter value.)
* Parameters match with only promotions from ``uniform`` to ``varying``
type.
* Parameters match using standard type conversion (``int`` to ``float``,
types.
* Parameters match using arbitrary type conversion, without changing
variability from ``uniform`` to ``varying`` (e.g., ``int`` to ``float``,
``float`` to ``int``.)
* Parameters match using arbitrary type conversion, including also changing
variability from ``uniform`` to ``varying`` as needed.
Also like C, arrays are passed to functions by reference.