This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
C++ PATCH: Structure location
- To: egcs-patches at egcs dot cygnus dot com
- Subject: C++ PATCH: Structure location
- From: Nathan Sidwell <nathan at acm dot org>
- Date: Wed, 02 Jun 1999 15:58:46 +0100
- Organization: University of Bristol
- Reply-To: nathan at compsci dot bristol dot ac dot uk
Hi,
the attached patch changes where a struct's location is remembered. The current
behaviour is to mark where the closing '}' is. The patched behaviour marks the
opening '{', which I think is a more informative location (being closer to the
structure name).
The comment in finish_struct about typedef's doesn't appear to be correct, and
this code currently has the effect of always wacking the line number.
3 of the test cases need mild patches to move //ERROR lines in accordance with
the patch.
Ok to install?
nathan
--
Dr Nathan Sidwell :: Computer Science Department :: Bristol University
I have seen the death of PhotoShop -- it is called GIMP
nathan@acm.org http://www.cs.bris.ac.uk/~nathan/ nathan@cs.bris.ac.uk
1999-06-02 Nathan Sidwell <nathan@acm.org>
* semantics.c (begin_class_definition): Update the struct's
location here ...
* class.c (finish_struct): ... rather than here.
Index: egcs/gcc/cp/class.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/class.c,v
retrieving revision 1.160
diff -c -3 -p -r1.160 class.c
*** class.c 1999/05/25 15:31:24 1.160
--- class.c 1999/06/02 14:37:52
*************** finish_struct (t, attributes, warn_anon)
*** 4173,4195 ****
tree t, attributes;
int warn_anon;
{
- tree name = TYPE_NAME (t);
-
- if (TREE_CODE (name) == TYPE_DECL)
- {
- extern int lineno;
-
- DECL_SOURCE_FILE (name) = input_filename;
- /* For TYPE_DECL that are not typedefs (those marked with a line
- number of zero, we don't want to mark them as real typedefs.
- If this fails one needs to make sure real typedefs have a
- previous line number, even if it is wrong, that way the below
- will fill in the right line number. (mrs) */
- if (DECL_SOURCE_LINE (name))
- DECL_SOURCE_LINE (name) = lineno;
- name = DECL_NAME (name);
- }
-
/* Append the fields we need for constructing signature tables. */
if (IS_SIGNATURE (t))
append_signature_fields (t);
--- 4173,4178 ----
Index: egcs/gcc/cp/semantics.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/semantics.c,v
retrieving revision 1.49
diff -c -3 -p -r1.49 semantics.c
*** semantics.c 1999/05/25 15:31:38 1.49
--- semantics.c 1999/06/02 14:38:16
*************** begin_class_definition (t)
*** 1297,1302 ****
--- 1297,1306 ----
else if (TYPE_SIZE (t))
duplicate_tag_error (t);
+ /* Update the location of the decl. */
+ DECL_SOURCE_FILE (TYPE_NAME (t)) = input_filename;
+ DECL_SOURCE_LINE (TYPE_NAME (t)) = lineno;
+
if (TYPE_BEING_DEFINED (t))
{
t = make_lang_type (TREE_CODE (t));
Index: egcs/gcc/testsuite/g++.old-deja/g++.pt/crash5.C
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/testsuite/g++.old-deja/g++.pt/crash5.C,v
retrieving revision 1.3
diff -c -3 -p -r1.3 crash5.C
*** crash5.C 1999/02/28 00:22:43 1.3
--- crash5.C 1999/06/02 14:38:48
***************
*** 1,9 ****
// Build don't link:
template <class T, int i>
! struct K {
void f();
! }; // ERROR - forward declaration
template <class T>
void
--- 1,9 ----
// Build don't link:
template <class T, int i>
! struct K { // ERROR - forward declaration
void f();
! };
template <class T>
void
Index: egcs/gcc/testsuite/g++.old-deja/g++.pt/t05.C
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/testsuite/g++.old-deja/g++.pt/t05.C,v
retrieving revision 1.4
diff -c -3 -p -r1.4 t05.C
*** t05.C 1998/12/16 22:00:30 1.4
--- t05.C 1999/06/02 14:38:50
***************
*** 1,9 ****
// Build don't link:
! template <class A> class B {
A a;
public:
B(A&aa); // ERROR - near match
~B();
! }; // ERROR - candidates
static B<int> b_int (3); // ERROR - no matching function
--- 1,9 ----
// Build don't link:
! template <class A> class B { // ERROR - candidates
A a;
public:
B(A&aa); // ERROR - near match
~B();
! };
static B<int> b_int (3); // ERROR - no matching function
Index: egcs/gcc/testsuite/g++.old-deja/g++.robertl/eb109.C
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/testsuite/g++.old-deja/g++.robertl/eb109.C,v
retrieving revision 1.5
diff -c -3 -p -r1.5 eb109.C
*** eb109.C 1998/12/16 22:02:58 1.5
--- eb109.C 1999/06/02 14:38:50
*************** inline istream& operator>>(istream& is,
*** 17,23 ****
template<class VertexType, class EdgeType>
class Graph
! {
public:
// public type interface
typedef map<int, EdgeType > Successor;
--- 17,23 ----
template<class VertexType, class EdgeType>
class Graph
! { // ERROR - candidates
public:
// public type interface
typedef map<int, EdgeType > Successor;
*************** class Graph
*** 32,38 ****
bool directed;
GraphType C; // container
ostream* pOut;
! }; // ERROR - candidates
// all graph-methods delet
template<class VertexType, class EdgeType>
--- 32,38 ----
bool directed;
GraphType C; // container
ostream* pOut;
! };
// all graph-methods delet
template<class VertexType, class EdgeType>