aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMark Mitchell <mark@codesourcery.com>2003-07-09 23:06:39 +0000
committerMark Mitchell <mmitchel@gcc.gnu.org>2003-07-09 23:06:39 +0000
commit279b84660bf493976de41fe1320690dcae3ec279 (patch)
tree01da5236669d609ce81b5e86fefc7f54e6b12b70 /gcc
parentbb498ea3a5c35c73f3ca3a89642637eec1c2c4a8 (diff)
downloadgcc-279b84660bf493976de41fe1320690dcae3ec279.zip
gcc-279b84660bf493976de41fe1320690dcae3ec279.tar.gz
gcc-279b84660bf493976de41fe1320690dcae3ec279.tar.bz2
parser.c (cp_parser_primary_expression): Preserve the form of qualified expressions in templates...
* parser.c (cp_parser_primary_expression): Preserve the form of qualified expressions in templates, even if they are not dependent. * pt.c (convert_nontype_argument): Handle non-dependent SCOPE_REFs. (tsubst_qualified_id): Likewise. * search.c (accessible_p): Treat everything in the body of a From-SVN: r69160
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog10
-rw-r--r--gcc/cp/parser.c11
-rw-r--r--gcc/cp/pt.c19
-rw-r--r--gcc/cp/search.c7
4 files changed, 38 insertions, 9 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 8d83247..4544e1b 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,13 @@
+2003-07-09 Mark Mitchell <mark@codesourcery.com>
+
+ * parser.c (cp_parser_primary_expression): Preserve the form of
+ qualified expressions in templates, even if they are not
+ dependent.
+ * pt.c (convert_nontype_argument): Handle non-dependent SCOPE_REFs.
+ (tsubst_qualified_id): Likewise.
+ * search.c (accessible_p): Treat everything in the body of a
+ template as accessible.
+
2003-07-08 Mark Mitchell <mark@codesourcery.com>
* cp-tree.def (NON_DEPENDENT_EXPR): New node.
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 19f55f4..60ec069 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -2648,6 +2648,12 @@ cp_parser_primary_expression (cp_parser *parser,
return build_nt (SCOPE_REF,
parser->scope,
id_expression);
+ else if (TYPE_P (parser->scope)
+ && DECL_P (decl))
+ return build (SCOPE_REF,
+ TREE_TYPE (decl),
+ parser->scope,
+ id_expression);
else
return decl;
}
@@ -2705,6 +2711,11 @@ cp_parser_primary_expression (cp_parser *parser,
*qualifying_class = parser->scope;
else if (!processing_template_decl)
decl = convert_from_reference (decl);
+ else if (TYPE_P (parser->scope))
+ decl = build (SCOPE_REF,
+ TREE_TYPE (decl),
+ parser->scope,
+ decl);
}
else
/* Transform references to non-static data members into
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 4d650c5..b4c9ced 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -3054,7 +3054,6 @@ convert_nontype_argument (tree type, tree expr)
goto bad_argument;
}
else if (TYPE_PTR_P (expr_type)
- || TYPE_PTRMEM_P (expr_type)
|| TREE_CODE (expr_type) == ARRAY_TYPE
|| TREE_CODE (type) == REFERENCE_TYPE
/* If expr is the address of an overloaded function, we
@@ -3100,6 +3099,9 @@ convert_nontype_argument (tree type, tree expr)
return NULL_TREE;
}
+ if (TREE_CODE (referent) == SCOPE_REF)
+ referent = TREE_OPERAND (referent, 1);
+
if (is_overloaded_fn (referent))
/* We'll check that it has external linkage later. */
;
@@ -7160,14 +7162,13 @@ tsubst_qualified_id (tree qualified_id, tree args,
}
expr = tsubst_copy (name, args, complain, in_decl);
- if (!BASELINK_P (name))
- {
- expr = lookup_qualified_name (scope, expr, /*is_type_p=*/0);
- if (DECL_P (expr))
- check_accessibility_of_qualified_id (expr,
- /*object_type=*/NULL_TREE,
- scope);
- }
+ if (!BASELINK_P (name)
+ && !DECL_P (expr))
+ expr = lookup_qualified_name (scope, expr, /*is_type_p=*/0);
+ if (DECL_P (expr))
+ check_accessibility_of_qualified_id (expr,
+ /*object_type=*/NULL_TREE,
+ scope);
/* Remember that there was a reference to this entity. */
if (DECL_P (expr))
diff --git a/gcc/cp/search.c b/gcc/cp/search.c
index 64e5707..c2c158a 100644
--- a/gcc/cp/search.c
+++ b/gcc/cp/search.c
@@ -903,6 +903,13 @@ accessible_p (tree type, tree decl)
if (!TYPE_P (context_for_name_lookup (decl)))
return 1;
+ /* In a template declaration, we cannot be sure whether the
+ particular specialization that is instantiated will be a friend
+ or not. Therefore, all access checks are deferred until
+ instantiation. */
+ if (processing_template_decl)
+ return 1;
+
if (!TYPE_P (type))
{
binfo = type;