aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@acm.org>2020-09-22 12:21:13 -0700
committerNathan Sidwell <nathan@acm.org>2020-09-22 12:31:39 -0700
commit7d8177b027b87cf3211e2d6cf144ec71616425ea (patch)
tree44a2dcbf283da2ba15f3d536fe70d5778a0a6a6e /gcc
parentbc13106e0414b86af8f6878e7681e6a959921b9e (diff)
downloadgcc-7d8177b027b87cf3211e2d6cf144ec71616425ea.zip
gcc-7d8177b027b87cf3211e2d6cf144ec71616425ea.tar.gz
gcc-7d8177b027b87cf3211e2d6cf144ec71616425ea.tar.bz2
c++: Remove a broken error-recovery path
The remaining use of xref_tag_from_type was also suspicious. It turns out to be an error path. At parse time we diagnose that a class definition cannot appear, but we swallow the definition. This code was attempting to push it into the global scope (or find a conflict). This seems needless, just return error_mark_node. This was the simpler fix than going through the parser and figuring out how to get it to put in error_mark_node at the right point. gcc/cp/ * cp-tree.h (xref_tag_from_type): Don't declare. * decl.c (xref_tag_from_type): Delete. * pt.c (lookup_template_class_1): Erroneously located class definitions just give error_mark, don't try and inject it into the namespace.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/cp-tree.h1
-rw-r--r--gcc/cp/decl.c17
-rw-r--r--gcc/cp/pt.c11
3 files changed, 5 insertions, 24 deletions
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 7135381..029a165 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -6502,7 +6502,6 @@ extern void grok_special_member_properties (tree);
extern bool grok_ctor_properties (const_tree, const_tree);
extern bool grok_op_properties (tree, bool);
extern tree xref_tag (enum tag_types, tree, tag_scope, bool);
-extern tree xref_tag_from_type (tree, tree, tag_scope);
extern void xref_basetypes (tree, tree);
extern tree start_enum (tree, tree, tree, tree, bool, bool *);
extern void finish_enum_value_list (tree);
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index bbecebe..f3fdfe3 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -15120,23 +15120,6 @@ xref_tag (enum tag_types tag_code, tree name,
return ret;
}
-
-tree
-xref_tag_from_type (tree old, tree id, tag_scope scope)
-{
- enum tag_types tag_kind;
-
- if (TREE_CODE (old) == RECORD_TYPE)
- tag_kind = (CLASSTYPE_DECLARED_CLASS (old) ? class_type : record_type);
- else
- tag_kind = union_type;
-
- if (id == NULL_TREE)
- id = TYPE_IDENTIFIER (old);
-
- return xref_tag (tag_kind, id, scope, false);
-}
-
/* Create the binfo hierarchy for REF with (possibly NULL) base list
BASE_LIST. For each element on BASE_LIST the TREE_PURPOSE is an
access_* node, and the TREE_VALUE is the type of the base-class.
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 44ca14a..69946da 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -9856,12 +9856,11 @@ lookup_template_class_1 (tree d1, tree arglist, tree in_decl, tree context,
&& !PRIMARY_TEMPLATE_P (gen_tmpl)
&& !LAMBDA_TYPE_P (TREE_TYPE (gen_tmpl))
&& TREE_CODE (CP_DECL_CONTEXT (gen_tmpl)) == NAMESPACE_DECL)
- {
- found = xref_tag_from_type (TREE_TYPE (gen_tmpl),
- DECL_NAME (gen_tmpl),
- /*tag_scope=*/ts_global);
- return found;
- }
+ /* This occurs when the user has tried to define a tagged type
+ in a scope that forbids it. We emitted an error during the
+ parse. We didn't complete the bail out then, so here we
+ are. */
+ return error_mark_node;
context = DECL_CONTEXT (gen_tmpl);
if (context && TYPE_P (context))