aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMark Mitchell <mark@codesourcery.com>1999-05-20 14:58:40 +0000
committerMark Mitchell <mmitchel@gcc.gnu.org>1999-05-20 14:58:40 +0000
commitb886540796da5203802db467343fbd379233912d (patch)
tree66dba41553d29c2a12093b3f74837a7783eb47c7 /gcc
parent6d813d4d850ce5b22d74f3479822dfe91c0fe35f (diff)
downloadgcc-b886540796da5203802db467343fbd379233912d.zip
gcc-b886540796da5203802db467343fbd379233912d.tar.gz
gcc-b886540796da5203802db467343fbd379233912d.tar.bz2
pt.c (for_each_template_parm): Rework to match documentation.
* pt.c (for_each_template_parm): Rework to match documentation. Don't be fooled by a COMPONENT_REF with no TREE_TYPE. From-SVN: r27066
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/pt.c36
-rw-r--r--gcc/testsuite/g++.old-deja/g++.pt/crash41.C11
3 files changed, 37 insertions, 16 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 5ac9e81..9ade541 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,8 @@
+1999-05-20 Mark Mitchell <mark@codesourcery.com>
+
+ * pt.c (for_each_template_parm): Rework to match documentation.
+ Don't be fooled by a COMPONENT_REF with no TREE_TYPE.
+
1999-05-20 Jason Merrill <jason@yorick.cygnus.com>
* class.c (finish_struct_1): Still check for ANON_AGGR_TYPE_P.
@@ -18,6 +23,7 @@
(cplus_expand_expr): Here. Use cplus_expand_constant.
(init_cplus_expand): Set lang_expand_constant.
* pt.c (convert_nontype_argument): Use make_ptrmem_cst.
+
* tree.c (make_ptrmem_cst): Define.
* typeck.c (unary_complex_lvalue): Use make_ptrmem_cst.
* typeck2.c (initializer_constant_valid_p): Use make_ptrmem_cst.
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 8c5622c..b26fecb 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -4019,13 +4019,6 @@ for_each_template_parm (t, fn, data)
switch (TREE_CODE (t))
{
- case INDIRECT_REF:
- case COMPONENT_REF:
- /* We assume that the object must be instantiated in order to build
- the COMPONENT_REF, so we test only whether the type of the
- COMPONENT_REF uses template parms. */
- return for_each_template_parm (TREE_TYPE (t), fn, data);
-
case ARRAY_REF:
case OFFSET_REF:
return (for_each_template_parm (TREE_OPERAND (t, 0), fn, data)
@@ -4183,10 +4176,6 @@ for_each_template_parm (t, fn, data)
/* NOTREACHED */
return 0;
- case LOOKUP_EXPR:
- case TYPENAME_TYPE:
- return 1;
-
case PTRMEM_CST:
return for_each_template_parm (TREE_TYPE (t), fn, data);
@@ -4199,6 +4188,21 @@ for_each_template_parm (t, fn, data)
(TREE_TYPE (t)), fn, data);
return for_each_template_parm (TREE_OPERAND (t, 1), fn, data);
+ case SIZEOF_EXPR:
+ case ALIGNOF_EXPR:
+ return for_each_template_parm (TREE_OPERAND (t, 0), fn, data);
+
+ case INDIRECT_REF:
+ case COMPONENT_REF:
+ /* We assume that the object must be instantiated in order to build
+ the COMPONENT_REF, so we test only whether the type of the
+ COMPONENT_REF uses template parms. On the other hand, if
+ there's no type, then this thing must be some expression
+ involving template parameters. */
+ if (TREE_TYPE (t))
+ return for_each_template_parm (TREE_TYPE (t), fn, data);
+ /* Fall through. */
+
case MODOP_EXPR:
case CAST_EXPR:
case REINTERPRET_CAST_EXPR:
@@ -4208,11 +4212,11 @@ for_each_template_parm (t, fn, data)
case ARROW_EXPR:
case DOTSTAR_EXPR:
case TYPEID_EXPR:
- return 1;
-
- case SIZEOF_EXPR:
- case ALIGNOF_EXPR:
- return for_each_template_parm (TREE_OPERAND (t, 0), fn, data);
+ case LOOKUP_EXPR:
+ case TYPENAME_TYPE:
+ if (!fn)
+ return 1;
+ /* Fall through. */
default:
switch (TREE_CODE_CLASS (TREE_CODE (t)))
diff --git a/gcc/testsuite/g++.old-deja/g++.pt/crash41.C b/gcc/testsuite/g++.old-deja/g++.pt/crash41.C
new file mode 100644
index 0000000..3ab7c15
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.pt/crash41.C
@@ -0,0 +1,11 @@
+// Build don't link:
+// Origin: Mark Mitchell <mark@codesourcery.com>
+
+template <int> struct S1{};
+
+struct S2 { int i; };
+
+template <class T>
+void f(S2 s2) {
+ S1<s2.i> s1;
+}