From eeb753839ff6f622aecf03483ecaedf69d7d25c5 Mon Sep 17 00:00:00 2001 From: Nathan Sidwell Date: Tue, 28 Nov 2000 10:18:25 +0000 Subject: [PATCH] decl.c (grokdeclarator): Diagnose undefined template contexts. cp: * decl.c (grokdeclarator): Diagnose undefined template contexts. testsuite: * g++.old-deja/g++.pt/incomplete1.C: New test. From-SVN: r37815 --- gcc/cp/ChangeLog | 4 ++++ gcc/cp/decl.c | 18 +++++------------- gcc/testsuite/ChangeLog | 4 ++++ .../g++.old-deja/g++.pt/incomplete1.C | 11 +++++++++++ 4 files changed, 24 insertions(+), 13 deletions(-) create mode 100644 gcc/testsuite/g++.old-deja/g++.pt/incomplete1.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index fa0940110aa..7f18e81350c 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,7 @@ +2000-11-28 Nathan Sidwell + + * decl.c (grokdeclarator): Diagnose undefined template contexts. + 2000-11-28 Nathan Sidwell * decl.c (grokdeclarator): Do type access control on friend diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index da74687aa1a..1c29bbf949c 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -10995,8 +10995,7 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist) } else if (TREE_CODE (type) == FUNCTION_TYPE) { - if (current_class_type == NULL_TREE - || friendp) + if (current_class_type == NULL_TREE || friendp) type = build_cplus_method_type (ctype, TREE_TYPE (type), TYPE_ARG_TYPES (type)); else @@ -11022,18 +11021,11 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist) } type = build_offset_type (ctype, type); } - else if (uses_template_parms (ctype)) - { - if (TREE_CODE (type) == FUNCTION_TYPE) - type - = build_cplus_method_type (ctype, TREE_TYPE (type), - TYPE_ARG_TYPES (type)); - } else - { - cp_error ("structure `%T' not yet defined", ctype); - return error_mark_node; - } + { + incomplete_type_error (NULL_TREE, ctype); + return error_mark_node; + } declarator = sname; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 66e472321a2..f827bf055e2 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2000-11-28 Nathan Sidwell + + * g++.old-deja/g++.pt/incomplete1.C: New test. + 2000-11-28 Nathan Sidwell * g++.old-deja/g++.other/friend9.C: New test. diff --git a/gcc/testsuite/g++.old-deja/g++.pt/incomplete1.C b/gcc/testsuite/g++.old-deja/g++.pt/incomplete1.C new file mode 100644 index 00000000000..c08e90cd652 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/incomplete1.C @@ -0,0 +1,11 @@ +// Build don't link: + +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 28 Nov 2000 + +// Inspired by by 756. We'd ICE when trying to define a member of an +// incomplete template type. + +template struct ObjCount; // ERROR - forward decl + +template int ObjCount::m; // ERROR - undefined type -- 2.30.2