diff options
author | Nathan Sidwell <nathan@codesourcery.com> | 2003-08-10 14:54:22 +0000 |
---|---|---|
committer | Nathan Sidwell <nathan@gcc.gnu.org> | 2003-08-10 14:54:22 +0000 |
commit | 86306a6b111cf8e6bef4c451761f3a458212a756 (patch) | |
tree | ebbe19ab3f32b618c056e966ef2359cd6a508112 /gcc | |
parent | 3372178cc3d73aeedb6afbd02871ce6cd6aea0af (diff) | |
download | gcc-86306a6b111cf8e6bef4c451761f3a458212a756.zip gcc-86306a6b111cf8e6bef4c451761f3a458212a756.tar.gz gcc-86306a6b111cf8e6bef4c451761f3a458212a756.tar.bz2 |
re PR c++/10530 (Cannot access non-dependent type within nested template)
cp:
PR c++/10530
* pt.c (dependent_type_p_r): A dependent template-id is a class
type with dependent template arguments, or a bound template
template parameter.
(type_dependent_expression_p): A template function decl cannot
have a dependent context.
testsuite:
PR c++/10530
* g++.dg/template/dependent-name2.C: New test.
From-SVN: r70293
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 9 | ||||
-rw-r--r-- | gcc/cp/pt.c | 25 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/template/dependent-name2.C | 24 |
4 files changed, 49 insertions, 14 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 9c89733..4db8e19 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,12 @@ +2003-08-10 Nathan Sidwell <nathan@codesourcery.com> + + PR c++/10530 + * pt.c (dependent_type_p_r): A dependent template-id is a class + type with dependent template arguments, or a bound template + template parameter. + (type_dependent_expression_p): A template function decl cannot + have a dependent context. + 2003-08-07 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net> PR c++/5767 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 706691c..a4e55c0 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -11348,25 +11348,23 @@ dependent_type_p_r (tree type) return true; return dependent_type_p (TREE_TYPE (type)); } + /* -- a template-id in which either the template name is a template - parameter or any of the template arguments is a dependent type or - an expression that is type-dependent or value-dependent. - - This language seems somewhat confused; for example, it does not - discuss template template arguments. Therefore, we use the - definition for dependent template arguments in [temp.dep.temp]. */ - if (CLASS_TYPE_P (type) && CLASSTYPE_TEMPLATE_INFO (type) - && (dependent_template_id_p - (CLASSTYPE_TI_TEMPLATE (type), - CLASSTYPE_TI_ARGS (type)))) + parameter ... */ + if (TREE_CODE (type) == BOUND_TEMPLATE_TEMPLATE_PARM) return true; - else if (TREE_CODE (type) == BOUND_TEMPLATE_TEMPLATE_PARM) + /* ... or any of the template arguments is a dependent type or + an expression that is type-dependent or value-dependent. */ + else if (CLASS_TYPE_P (type) && CLASSTYPE_TEMPLATE_INFO (type) + && any_dependent_template_arguments_p (CLASSTYPE_TI_ARGS (type))) return true; + /* All TYPEOF_TYPEs are dependent; if the argument of the `typeof' expression is not type-dependent, then it should already been have resolved. */ if (TREE_CODE (type) == TYPEOF_TYPE) return true; + /* The standard does not specifically mention types that are local to template functions or local classes, but they should be considered dependent too. For example: @@ -11616,9 +11614,8 @@ type_dependent_expression_p (tree expression) if (TREE_CODE (expression) == FUNCTION_DECL && DECL_LANG_SPECIFIC (expression) && DECL_TEMPLATE_INFO (expression) - && (dependent_template_id_p - (DECL_TI_TEMPLATE (expression), - INNERMOST_TEMPLATE_ARGS (DECL_TI_ARGS (expression))))) + && (any_dependent_template_arguments_p + (INNERMOST_TEMPLATE_ARGS (DECL_TI_ARGS (expression))))) return true; if (TREE_TYPE (expression) == unknown_type_node) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a536a70..34e5185 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2003-08-10 Nathan Sidwell <nathan@codesourcery.com> + + PR c++/10530 + * g++.dg/template/dependent-name2.C: New test. + 2003-08-08 Andrew Pinski <pinskia@physics.uc.edu> * g++.dg/parse/crash11.C: Put the dg options in comments. diff --git a/gcc/testsuite/g++.dg/template/dependent-name2.C b/gcc/testsuite/g++.dg/template/dependent-name2.C new file mode 100644 index 0000000..611d5f9 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/dependent-name2.C @@ -0,0 +1,24 @@ +// { dg-do compile } + +// Copyright (C) 2003 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 1 Aug 2003 <nathan@codesourcery.com> + +// PR 10530. Thought a type was dependent. + +template <typename T> +struct Foo { + struct Inner { + typedef int type; + }; +}; + +template <typename A> struct Bar { + typedef typename Foo<int>::Inner::type type; +}; + +template <template <typename T> class TPL> void Foo () +{ + TPL<int> x; + + f (x); +} |