OSDN Git Service

PR c++/13289
authorlerdsuwa <lerdsuwa@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 29 Dec 2003 11:00:36 +0000 (11:00 +0000)
committerlerdsuwa <lerdsuwa@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 29 Dec 2003 11:00:36 +0000 (11:00 +0000)
* semantics.c (finish_id_expression): Only check if the type of
a template argument is integral or enumeration when it is not
dependent.

* g++.dg/parse/nontype1.C: New test.

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

gcc/cp/ChangeLog
gcc/cp/semantics.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/parse/nontype1.C [new file with mode: 0644]

index 1cceeb8..72c0f5f 100644 (file)
@@ -1,5 +1,12 @@
 2003-12-29  Kriang Lerdsuwanakij  <lerdsuwa@users.sourceforge.net>
 
+       PR c++/13289
+       * semantics.c (finish_id_expression): Only check if the type of
+       a template argument is integral or enumeration when it is not
+       dependent.
+
+2003-12-29  Kriang Lerdsuwanakij  <lerdsuwa@users.sourceforge.net>
+
        PR c++/12403
        * parser.c (cp_parser_template_declaration_after_export): Set up
        template specialization scope in case of explicit specialization.
index c9a4a68..4cf0261 100644 (file)
@@ -2400,6 +2400,7 @@ finish_id_expression (tree id_expression,
       if (TREE_CODE (decl) == TEMPLATE_PARM_INDEX)
        decl = TEMPLATE_PARM_DECL (decl);
       if (integral_constant_expression_p 
+         && !dependent_type_p (TREE_TYPE (decl))
          && !INTEGRAL_OR_ENUMERATION_TYPE_P (TREE_TYPE (decl))) 
        {
          if (!allow_non_integral_constant_expression_p)
index 14faa0d..2cccfdd 100644 (file)
@@ -1,5 +1,10 @@
 2003-12-29  Kriang Lerdsuwanakij  <lerdsuwa@users.sourceforge.net>
 
+       PR c++/13289
+       * g++.dg/parse/nontype1.C: New test.
+
+2003-12-29  Kriang Lerdsuwanakij  <lerdsuwa@users.sourceforge.net>
+
        PR c++/12403
        * g++.dg/parse/explicit1.C: New test.
        * g++.old-deja/g++.pt/explicit71.C: Adjust expected error.
diff --git a/gcc/testsuite/g++.dg/parse/nontype1.C b/gcc/testsuite/g++.dg/parse/nontype1.C
new file mode 100644 (file)
index 0000000..e721700
--- /dev/null
@@ -0,0 +1,9 @@
+// Copyright (C) 2003 Free Software Foundation
+// Contributed by Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
+// { dg-do compile }
+
+// PR c++/13289: Incorrectly reject non-type template argument that has
+// dependent type
+
+template <class T, T t> class C {};
+template <class T, T t> class D { C<T, t-1> c; };