This is the mail archive of the gcc-patches@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: [C++ PATCH] [PR13810] ICE on default argument for template template parameter (3.4/3.5 regression)


"Giovanni Bajo" <giovannibajo@libero.it> writes:

| Moreover, check_template_template_default_arg was accepting TYPE_DECL as a
| valid default argument. I can't see how that could have ever been correct. I
| fixed it and also provided more detailed diagnostics for common cases.

[...]

| --- 1942,1967 ----
|   {
|     if (TREE_CODE (argument) != TEMPLATE_DECL
|         && TREE_CODE (argument) != TEMPLATE_TEMPLATE_PARM
|         && TREE_CODE (argument) != UNBOUND_CLASS_TEMPLATE)
|       {
| !       if (TREE_CODE (argument) == TYPE_DECL)
| !  {
| !    tree t = TREE_TYPE (argument);
| !
| !    /* Try to emit a slightly smarter error message if we detect
| !       that the user is using a template instantiation.  */
| !    if (CLASSTYPE_TEMPLATE_INFO (t)
| !        && CLASSTYPE_TEMPLATE_INSTANTIATION (t))
| !      error ("`%D' is a template instantiation and cannot be used as a "
| !      "default argument for a template template parameter",

consider:

         error ("invalid use of type '%T' used as default value "
                "for a template template-parameter", 
         
Please, notice the use of '%T' instead of '%D'.
                   
| !      argument);
| !    else
| !      error ("`%D' is not a template class and cannot be used as a "
| !      "default argument for a template template parameter",
| !      argument);

         error ("invalid use of '%D' as default value for a template "
                "template-argument", argument)

The point being that in the near future 

    template<class> class TTP

may not just means that TTTP ought to be a template /class/; it may
just be a template alias.  And the diagnostic is just as clear. 

-- Gaby


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