This is the mail archive of the 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]

[lto] tree.h: Add arg_type to tree_parm_decl.


Attached is a patch to add a new member, arg_type, to tree_parm_decl.

The story to justify this new member is somewhat long, so please bare
with me.

One of the things we'd like to do on the LTO branch is to eliminate
TREE_LIST.  As you might know, one of the biggest users of TREE_LIST
is code to handle function types.  Specifically, TYPE_ARG_TYPES points
to a linked list of TREE_LIST objects with each TREE_VALUE pointing to
a type.  Now, the C++ frontend uses the TREE_PURPOSE field of a
TREE_LIST object to store default arguments of a function.  We
eventually want TREE_ARG_TYPES to point to a vector of argument types,
not a vector of ordered pairs of a argument type and a default
argument.  We then want to store a default argument in the
DECL_INITIAL field of a PARM_DECL.  This in turn forces us to kick out
any existing use of the DECL_INITIAL field of a PARM_DECL, which
happens to be DECL_ARG_TYPE.

This patch frees up the DECL_INITIAL field of a PARM_DECL by adding a
new member, arg_type.

Note that we will eliminate one instance of TREE_LIST for every
PARM_DECL, so we'll win overall even with this new field.

One caveat.  This patch changes locate_old_decl in a very minor way.
Without this patch, a decl would have its DECL_INITIAL nonzero because
DECL_ARG_TYPE was using the same slot.  This causes "previous
definition of ... was here" to be output.  With this patch,
DECL_INITIAL is NULL, so locate_old_decl prints out "previous
declaration of ... was here".  For function arguments, declaration and
definition seem to be very fuzzy.  I thought Joseph Myers might care,
but he said he didn't in private communication, so I decided to let
locate_old_decl change its behavior and fix testcases.

Tested on x86_64-pc-linux-gnu.  OK to apply to the LTO branch?

Kazu Hirata

2006-06-01  Kazu Hirata  <>

	* tree.h (DECL_ARG_TYPE): Use parm_decl.arg_type.
	(tree_parm_decl): Add arg_type.

2006-06-01  Kazu Hirata  <>

	* gcc.dg/Wshadow-1.c, gcc.dg/decl-4.c,
	gcc.dg/parm-forwdecl-1.c: Look for "declaration"
	instead of "definition".

Index: testsuite/gcc.dg/Wshadow-1.c
--- testsuite/gcc.dg/Wshadow-1.c	(revision 114242)
+++ testsuite/gcc.dg/Wshadow-1.c	(working copy)
@@ -10,7 +10,7 @@ void foo (double decl1)		/* { dg-warning
-void foo1 (int d)		/* { dg-warning "previous definition" } */
+void foo1 (int d)		/* { dg-warning "previous declaration" } */
   double d;	 /* { dg-bogus "warning" "warning in place of error" } */
   /* { dg-error "redeclared as different" "" { target *-*-* } 15 } */
Index: testsuite/gcc.dg/decl-4.c
--- testsuite/gcc.dg/decl-4.c	(revision 114242)
+++ testsuite/gcc.dg/decl-4.c	(working copy)
@@ -1,10 +1,10 @@
 /* Redeclaration of parameters is an error.  PR 13728.  */
 /* { dg-do compile } */
-void f (int fred,	/* { dg-error "previous definition" "" } */
+void f (int fred,	/* { dg-error "previous declaration" "" } */
 	int fred);	/* { dg-error "redefinition of parameter" "" } */
-void f2 (int fred,	/* { dg-error "previous definition" "" } */
+void f2 (int fred,	/* { dg-error "previous declaration" "" } */
 	 int fred)	/* { dg-error "redefinition of parameter" "" } */
Index: testsuite/gcc.dg/parm-forwdecl-1.c
--- testsuite/gcc.dg/parm-forwdecl-1.c	(revision 114242)
+++ testsuite/gcc.dg/parm-forwdecl-1.c	(working copy)
@@ -23,4 +23,4 @@ int g4(int, long;); /* { dg-error "just 
 /* Invalid uses.  */
 int h1(int a; int b); /* { dg-error "just a forward declaration" } */
 int h2(int; int b); /* { dg-error "just a forward declaration" } */
-int h3(int a; long a); /* { dg-error "conflicting types|previous definition|just a forward declaration" } */
+int h3(int a; long a); /* { dg-error "conflicting types|previous declaration|just a forward declaration" } */
Index: tree.h
--- tree.h	(revision 114242)
+++ tree.h	(working copy)
@@ -2724,7 +2724,7 @@ struct tree_const_decl GTY(())
 /* For a PARM_DECL, records the data type used to pass the argument,
    which may be different from the type seen in the program.  */
-#define DECL_ARG_TYPE(NODE) (PARM_DECL_CHECK (NODE)->decl_common.initial)
+#define DECL_ARG_TYPE(NODE) (PARM_DECL_CHECK (NODE)->parm_decl.arg_type)
 /* For PARM_DECL, holds an RTL for the stack slot or register
    where the data was actually passed.  */
@@ -2733,6 +2733,7 @@ struct tree_const_decl GTY(())
 struct tree_parm_decl GTY(())
   struct tree_decl_with_rtl common;
+  tree arg_type;
   rtx incoming_rtl;  

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