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]

[C++ PATCH] Fix dump of FUNCTION_DECL within expressions (a regression)


Hello,

this little patch fixes the dump of a FUNCTION_DECL within an expression so
that the argument types are not shown. For the given testcase, before we
were emitting:

error7.C:10: error: non-constant `func(double)(g)' cannot be used as
template argument

After the patch, the message is:

error7.C:10: error: non-constant `func(g)' cannot be used as template
argument

This is a regression against 2.95, which was emitting: the correct message.
The infrastructure to skip the argument types was already in place, but it
was surrounded by "if (1)".

The patch has been bootstrapped on i686-pc-cygwin (c, c++, java), and
regtested with "make check-g++", with no new regressions. OK for mainline?
OK for branch?

Giovanni Bajo


2003-06-24  Giovanni Bajo  <giovannibajo@libero.it>

        * cp_tree.h: Added TFF_NO_FUNCTION_ARGUMENTS.
        * error.c (dump_function_decl): Use it to skip the dump of the
        arguments.
        (dump_expr): When dumping a declaration found within an
        expression, always set TFF_NO_FUNCTION_ARGUMENTS
        in the flags.


2003-06-24  Giovanni Bajo  <giovannibajo@libero.it>

        * g++.dg/parse/error7.C: New test.


Index: cp-tree.h
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/cp/cp-tree.h,v
retrieving revision 1.847
diff -c -w -p -r1.847 cp-tree.h
*** cp-tree.h   18 May 2003 13:40:52 -0000      1.847
--- cp-tree.h   24 Jun 2003 01:11:52 -0000
*************** enum overload_flags { NO_SPECIAL = 0, DT
*** 3428,3434 ****
     TFF_TEMPLATE_HEADER: show the template<...> header in a
         template-declaration.
     TFF_TEMPLATE_NAME: show only template-name.
!    TFF_EXPR_IN_PARENS: Parenthesize expressions.  */

  #define TFF_PLAIN_IDENTIFIER               (0)
  #define TFF_SCOPE                        (1)
--- 3428,3435 ----
     TFF_TEMPLATE_HEADER: show the template<...> header in a
         template-declaration.
     TFF_TEMPLATE_NAME: show only template-name.
!    TFF_EXPR_IN_PARENS: parenthesize expressions.
!    TFF_NO_FUNCTION_ARGUMENTS: don't show function arguments.  */

  #define TFF_PLAIN_IDENTIFIER               (0)
  #define TFF_SCOPE                        (1)
*************** enum overload_flags { NO_SPECIAL = 0, DT
*** 3441,3446 ****
--- 3442,3448 ----
  #define TFF_TEMPLATE_HEADER                (1 << 7)
  #define TFF_TEMPLATE_NAME                  (1 << 8)
  #define TFF_EXPR_IN_PARENS                 (1 << 9)
+ #define TFF_NO_FUNCTION_ARGUMENTS          (1 << 10)

  /* Returns the TEMPLATE_DECL associated to a TEMPLATE_TEMPLATE_PARM
     node.  */
Index: error.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/cp/error.c,v
retrieving revision 1.208
diff -c -w -p -r1.208 error.c
*** error.c     21 May 2003 01:39:38 -0000      1.208
--- error.c     24 Jun 2003 01:09:36 -0000
*************** dump_function_decl (tree t, int flags)
*** 1128,1134 ****

    dump_function_name (t, flags);

!   if (1)
      {
        dump_parameters (parmtypes, flags);

--- 1128,1134 ----

    dump_function_name (t, flags);

!   if (!(flags & TFF_NO_FUNCTION_ARGUMENTS))
      {
        dump_parameters (parmtypes, flags);
*************** dump_expr (tree t, int flags)
*** 1411,1417 ****
      case NAMESPACE_DECL:
      case OVERLOAD:
      case IDENTIFIER_NODE:
!       dump_decl (t, flags & ~TFF_DECL_SPECIFIERS);
        break;

      case INTEGER_CST:
--- 1411,1417 ----
      case NAMESPACE_DECL:
      case OVERLOAD:
      case IDENTIFIER_NODE:
!       dump_decl (t, (flags & ~TFF_DECL_SPECIFIERS) |
TFF_NO_FUNCTION_ARGUMENTS);
        break;


// { dg-do compile }
// Properly print CALL_EXPRs while dumping expressions

double g;
int func(double);

template <int>
struct Foo {};

Foo<func(g)> f; // { dg-error "" "func(g)" }


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