From 0c83a0fcff9df31e594bcf7d888c7842b940b003 Mon Sep 17 00:00:00 2001 From: Nathan Sidwell Date: Wed, 2 Jul 2003 09:36:20 +0000 Subject: [PATCH] re PR c++/9779 (ICE in type_unknown_p when casting in static member) cp: PR c++/9779 * decl2.c (arg_assoc_class): Don't die on NULL type. * typeck.c (type_unknown_p): Don't die on untyped expressions. testsuite: PR c++/9779 * g++.dg/template/dependent-expr1.C: New. From-SVN: r68824 --- gcc/cp/ChangeLog | 6 ++++ gcc/cp/decl2.c | 5 ++++ gcc/cp/typeck.c | 6 +++- gcc/testsuite/ChangeLog | 5 ++++ .../g++.dg/template/dependent-expr1.C | 29 +++++++++++++++++++ 5 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/template/dependent-expr1.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index c0480b97c56..c8bb8930c70 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2003-07-02 Nathan Sidwell + + PR c++/9779 + * decl2.c (arg_assoc_class): Don't die on NULL type. + * typeck.c (type_unknown_p): Don't die on untyped expressions. + 2003-07-01 Mark Mitchell PR c++/6949 diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index c6217936918..c3b7cd0d518 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -4057,6 +4057,11 @@ arg_assoc_class (struct arg_lookup *k, tree type) static bool arg_assoc_type (struct arg_lookup *k, tree type) { + /* As we do not get the type of non-type dependent expressions + right, we can end up with such things without a type. */ + if (!type) + return false; + switch (TREE_CODE (type)) { case ERROR_MARK: diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 6c17089192d..4900cbffb17 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -183,7 +183,11 @@ type_unknown_p (exp) return (TREE_CODE (exp) == OVERLOAD || TREE_CODE (exp) == TREE_LIST || TREE_TYPE (exp) == unknown_type_node - || (TREE_CODE (TREE_TYPE (exp)) == OFFSET_TYPE + /* Until we get the type of non type-dependent expressions + correct, we can have non-type dependent expressions with + no type. */ + || (TREE_TYPE (exp) + && TREE_CODE (TREE_TYPE (exp)) == OFFSET_TYPE && TREE_TYPE (TREE_TYPE (exp)) == unknown_type_node)); } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 3d9914d8dfb..1a4d547818b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2003-07-02 Nathan Sidwell + + PR c++/9779 + * g++.dg/template/dependent-expr1.C: New. + 2003-07-01 Mark Mitchell PR c++/6949 diff --git a/gcc/testsuite/g++.dg/template/dependent-expr1.C b/gcc/testsuite/g++.dg/template/dependent-expr1.C new file mode 100644 index 00000000000..079f033611b --- /dev/null +++ b/gcc/testsuite/g++.dg/template/dependent-expr1.C @@ -0,0 +1,29 @@ +// { dg-do compile } + +// Copyright (C) 2003 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 30 Jun 2003 + +// PR c++ 9779. ICE + +struct I +{ +}; + +void Foo (int); +namespace std +{ + template + void Baz (I *x) + { + Foo (sizeof (I)); + Foo (sizeof (x)); + Foo (__alignof__ (I)); + Foo (__alignof__ (x)); + Foo (x->~I ()); + // Foo (typeid (I)); + Foo (delete x); + Foo (delete[] x); + Foo (throw x); + } + +} -- 2.30.2