summaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authormmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>2003-07-11 08:20:19 +0000
committermmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>2003-07-11 08:20:19 +0000
commit877a501e6e18f74bc9b0edc59e5318188a7c0fef (patch)
treeea270a6bb429742026b2cc05b98f103d36ac8fb3 /gcc
parent37c009d60da396a6d065075a91d5f9ff9066669f (diff)
downloadgcc-877a501e6e18f74bc9b0edc59e5318188a7c0fef.tar.gz
PR c++/8327
* pt.c (tsubst_qualified_id): Implement suggested resolution for Core Issue 2. (type_dependent_expression_p): Likewise. PR c++/8327 * g++.dg/template/scope1.C: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@69223 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog7
-rw-r--r--gcc/cp/pt.c50
-rw-r--r--gcc/testsuite/ChangeLog3
-rw-r--r--gcc/testsuite/g++.dg/template/scope1.C12
4 files changed, 65 insertions, 7 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 5722e9f3d53..d64d722303b 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,10 @@
+2003-07-11 Mark Mitchell <mark@codesourcery.com>
+
+ PR c++/8327
+ * pt.c (tsubst_qualified_id): Implement suggested resolution for
+ Core Issue 2.
+ (type_dependent_expression_p): Likewise.
+
2003-07-10 Mark Mitchell <mark@codesourcery.com>
* typeck.c (build_binary_op): Do not warn about signed
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index b4c9cedfad8..96edfc9f6f1 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -7142,10 +7142,6 @@ tsubst_qualified_id (tree qualified_id, tree args,
my_friendly_assert (TREE_CODE (qualified_id) == SCOPE_REF, 20030706);
- /* Look up the qualified name. */
- scope = TREE_OPERAND (qualified_id, 0);
- scope = tsubst (scope, args, complain, in_decl);
-
/* Figure out what name to look up. */
name = TREE_OPERAND (qualified_id, 1);
if (TREE_CODE (name) == TEMPLATE_ID_EXPR)
@@ -7161,7 +7157,18 @@ tsubst_qualified_id (tree qualified_id, tree args,
template_args = NULL_TREE;
}
- expr = tsubst_copy (name, args, complain, in_decl);
+ /* Substitute into the qualifying scope. When there are no ARGS, we
+ are just trying to simplify a non-dependent expression. In that
+ case the qualifying scope may be dependent, and, in any case,
+ substituting will not help. */
+ scope = TREE_OPERAND (qualified_id, 0);
+ if (args)
+ {
+ scope = tsubst (scope, args, complain, in_decl);
+ expr = tsubst_copy (name, args, complain, in_decl);
+ }
+ else
+ expr = name;
if (!BASELINK_P (name)
&& !DECL_P (expr))
expr = lookup_qualified_name (scope, expr, /*is_type_p=*/0);
@@ -7169,10 +7176,14 @@ tsubst_qualified_id (tree qualified_id, tree args,
check_accessibility_of_qualified_id (expr,
/*object_type=*/NULL_TREE,
scope);
-
+
/* Remember that there was a reference to this entity. */
if (DECL_P (expr))
- mark_used (expr);
+ {
+ mark_used (expr);
+ if (!args && TREE_CODE (expr) == VAR_DECL)
+ expr = DECL_INITIAL (expr);
+ }
if (is_template)
lookup_template_function (expr, template_args);
@@ -11594,6 +11605,31 @@ type_dependent_expression_p (tree expression)
return dependent_type_p (type);
}
+ /* [temp.dep.expr]
+
+ An id-expression is type-dependent if it contains a
+ nested-name-specifier that contains a class-name that names a
+ dependent type. */
+ if (TREE_CODE (expression) == SCOPE_REF
+ && TYPE_P (TREE_OPERAND (expression, 0)))
+ {
+ tree scope;
+ tree name;
+
+ scope = TREE_OPERAND (expression, 0);
+ name = TREE_OPERAND (expression, 1);
+
+ /* The suggested resolution to Core Issue 2 implies that if the
+ qualifying type is the current class, then we must peek
+ inside it. */
+ if (DECL_P (name)
+ && currently_open_class (scope)
+ && !type_dependent_expression_p (name))
+ return false;
+ if (dependent_type_p (scope))
+ return true;
+ }
+
if (TREE_CODE (expression) == FUNCTION_DECL
&& DECL_LANG_SPECIFIC (expression)
&& DECL_TEMPLATE_INFO (expression)
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 968a056df17..8f4579419a7 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,8 @@
2003-07-11 Mark Mitchell <mark@codesourcery.com>
+ PR c++/8327
+ * g++.dg/template/scope1.C: New test.
+
* g++.dg/warn/Wsign-compare-1.C: New test.
2003-07-10 Kazu Hirata <kazu@cs.umass.edu>
diff --git a/gcc/testsuite/g++.dg/template/scope1.C b/gcc/testsuite/g++.dg/template/scope1.C
new file mode 100644
index 00000000000..b017b0bdb9b
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/scope1.C
@@ -0,0 +1,12 @@
+// PR 8327
+
+template <class T>
+class X
+{
+ static const int a = 5;
+
+ static T b[a];
+};
+
+template <class T> T X<T>::b[X::a];
+