re PR c++/9779 (ICE in type_unknown_p when casting in static member)
authorNathan Sidwell <nathan@codesourcery.com>
Wed, 2 Jul 2003 09:36:20 +0000 (09:36 +0000)
committerNathan Sidwell <nathan@gcc.gnu.org>
Wed, 2 Jul 2003 09:36:20 +0000 (09:36 +0000)
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
gcc/cp/decl2.c
gcc/cp/typeck.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/template/dependent-expr1.C [new file with mode: 0644]

index c0480b97c5660d3c0298e9688445b33d8e8928ef..c8bb8930c7003812bbaeb30650daa1a3f84bd933 100644 (file)
@@ -1,3 +1,9 @@
+2003-07-02  Nathan Sidwell  <nathan@codesourcery.com>
+
+       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  <mark@codesourcery.com>
 
        PR c++/6949
index c6217936918c2b8b1a53d5dcc7601a591e46432a..c3b7cd0d5181323f245578b108d7e5422850a1e6 100644 (file)
@@ -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:
index 6c17089192d1536d909920df686506a344570add..4900cbffb1764e7d90ccd933513516104f3d68ed 100644 (file)
@@ -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));
 }
 
index 3d9914d8dfb375234525284548ed709b6a0d280e..1a4d547818b03cf4f486940829a040db9c489934 100644 (file)
@@ -1,3 +1,8 @@
+2003-07-02  Nathan Sidwell  <nathan@codesourcery.com>
+
+       PR c++/9779
+       * g++.dg/template/dependent-expr1.C: New.
+
 2003-07-01  Mark Mitchell  <mark@codesourcery.com>
 
        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 (file)
index 0000000..079f033
--- /dev/null
@@ -0,0 +1,29 @@
+// { dg-do compile }
+
+// Copyright (C) 2003 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 30 Jun 2003 <nathan@codesourcery.com>
+
+// PR c++ 9779. ICE
+
+struct I 
+{
+};
+
+void Foo (int);
+namespace std
+{
+  template <typename X>
+  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);
+  }
+
+}