From b4f70b3d4214872f1bb55c2f63c0ce030d4f8bb8 Mon Sep 17 00:00:00 2001 From: Nathan Sidwell Date: Thu, 3 Jun 1999 07:16:15 +0000 Subject: [PATCH] semantics.c (begin_class_definition): Update the struct's location here ... * semantics.c (begin_class_definition): Update the struct's location here ... * class.c (finish_struct): ... rather than here. * decl.c (make_typename_type): Don't rely on uninitialized variable. From-SVN: r27326 --- gcc/cp/ChangeLog | 9 +++++++++ gcc/cp/class.c | 17 ----------------- gcc/cp/decl.c | 10 +++++----- gcc/cp/semantics.c | 4 ++++ gcc/testsuite/g++.old-deja/g++.pt/crash5.C | 4 ++-- gcc/testsuite/g++.old-deja/g++.pt/t05.C | 4 ++-- gcc/testsuite/g++.old-deja/g++.robertl/eb109.C | 4 ++-- 7 files changed, 24 insertions(+), 28 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index d145518bdd1..49ea8bc609e 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,12 @@ +1999-06-03 Nathan Sidwell + + * semantics.c (begin_class_definition): Update the struct's + location here ... + * class.c (finish_struct): ... rather than here. + + * decl.c (make_typename_type): Don't rely on uninitialized + variable. + 1999-05-31 Kaveh R. Ghazi * Makefile.in (ALL_CFLAGS): Add '-W -Wall'. diff --git a/gcc/cp/class.c b/gcc/cp/class.c index c6d6bcc84e8..4fe5353edb6 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -4173,23 +4173,6 @@ finish_struct (t, attributes, warn_anon) 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); diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index c30fa7caf59..ac9933c819a 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -5516,7 +5516,6 @@ tree make_typename_type (context, name) tree context, name; { - tree t; tree fullname; if (TREE_CODE_CLASS (TREE_CODE (name)) == 't') @@ -5576,14 +5575,15 @@ make_typename_type (context, name) } else { - if (IS_AGGR_TYPE (context)) - t = lookup_field (context, name, 0, 1); - else + tree t; + + if (!IS_AGGR_TYPE (context)) { cp_error ("no type named `%#T' in `%#T'", name, context); return error_mark_node; } + t = lookup_field (context, name, 0, 1); if (t) return TREE_TYPE (t); } @@ -5591,7 +5591,7 @@ make_typename_type (context, name) /* If the CONTEXT is not a template type, then either the field is there now or its never going to be. */ - if (!uses_template_parms (context) && !t) + if (!uses_template_parms (context)) { cp_error ("no type named `%#T' in `%#T'", name, context); return error_mark_node; diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 5be0ae18326..37fb9da07d2 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -1297,6 +1297,10 @@ begin_class_definition (t) 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)); diff --git a/gcc/testsuite/g++.old-deja/g++.pt/crash5.C b/gcc/testsuite/g++.old-deja/g++.pt/crash5.C index 5797eee23e6..99a77916287 100644 --- a/gcc/testsuite/g++.old-deja/g++.pt/crash5.C +++ b/gcc/testsuite/g++.old-deja/g++.pt/crash5.C @@ -1,9 +1,9 @@ // Build don't link: template -struct K { +struct K { // ERROR - forward declaration void f(); -}; // ERROR - forward declaration +}; template void diff --git a/gcc/testsuite/g++.old-deja/g++.pt/t05.C b/gcc/testsuite/g++.old-deja/g++.pt/t05.C index 5c99f772ad9..6dab744b357 100644 --- a/gcc/testsuite/g++.old-deja/g++.pt/t05.C +++ b/gcc/testsuite/g++.old-deja/g++.pt/t05.C @@ -1,9 +1,9 @@ // Build don't link: -template class B { +template class B { // ERROR - candidates A a; public: B(A&aa); // ERROR - near match ~B(); -}; // ERROR - candidates +}; static B b_int (3); // ERROR - no matching function diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb109.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb109.C index ccd206b0e2c..ff7bc5c6c7e 100644 --- a/gcc/testsuite/g++.old-deja/g++.robertl/eb109.C +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb109.C @@ -17,7 +17,7 @@ inline istream& operator>>(istream& is, Empty& ) { return is;} template class Graph -{ +{ // ERROR - candidates public: // public type interface typedef map Successor; @@ -32,7 +32,7 @@ class Graph bool directed; GraphType C; // container ostream* pOut; -}; // ERROR - candidates +}; // all graph-methods delet template -- 2.30.2