OSDN Git Service

PR c++/10347
authorlerdsuwa <lerdsuwa@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 17 Apr 2003 14:05:54 +0000 (14:05 +0000)
committerlerdsuwa <lerdsuwa@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 17 Apr 2003 14:05:54 +0000 (14:05 +0000)
* pt.c (type_dependent_expression_p): Handle array new.

g++.dg/template/dependent-name1.C: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@65742 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/template/dependent-name1.C [new file with mode: 0644]

index 7ce1498..093198c 100644 (file)
@@ -1,3 +1,8 @@
+2003-04-17  Kriang Lerdsuwanakij  <lerdsuwa@users.sourceforge.net>
+
+       PR c++/10347
+       * pt.c (type_dependent_expression_p): Handle array new.
+
 2003-04-15  Mark Mitchell  <mark@codesourcery.com>
 
        PR c++/10381
index c8e7c40..41baea5 100644 (file)
@@ -11562,7 +11562,20 @@ type_dependent_expression_p (expression)
      by the expression.  */
   else if (TREE_CODE (expression) == NEW_EXPR
           || TREE_CODE (expression) == VEC_NEW_EXPR)
-    return dependent_type_p (TREE_OPERAND (expression, 1));
+    {
+      /* For NEW_EXPR tree nodes created inside a template, either
+        the object type itself or a TREE_LIST may appear as the
+        operand 1.  */
+      tree type = TREE_OPERAND (expression, 1);
+      if (TREE_CODE (type) == TREE_LIST)
+       /* This is an array type.  We need to check array dimensions
+          as well.  */
+       return dependent_type_p (TREE_VALUE (TREE_PURPOSE (type)))
+              || value_dependent_expression_p
+                   (TREE_OPERAND (TREE_VALUE (type), 1));
+      else
+       return dependent_type_p (type);
+    }
 
   if (TREE_CODE (expression) == FUNCTION_DECL
       && DECL_LANG_SPECIFIC (expression)
index b289626..bae6d9e 100644 (file)
@@ -1,3 +1,8 @@
+2003-04-17  Kriang Lerdsuwanakij  <lerdsuwa@users.sourceforge.net>
+
+       PR c++/10347
+       g++.dg/template/dependent-name1.C: New test.
+
 2003-04-17  J"orn Rennecke <joern.rennecke@superh.com>
 
        * gcc.dg/warn-1.c (tourist_guide): New array,
diff --git a/gcc/testsuite/g++.dg/template/dependent-name1.C b/gcc/testsuite/g++.dg/template/dependent-name1.C
new file mode 100644 (file)
index 0000000..60ab344
--- /dev/null
@@ -0,0 +1,11 @@
+// { dg-do compile }
+
+// Origin: Wolfgang Bangerth <bangerth@ticam.utexas.edu>
+
+// PR c++/10347: Dependent type checking of array new expression
+
+void bar (int *);
+    
+template <int> void foo() {
+  bar(new int[1]);
+}