re PR c++/21165 (bogus error on a user-defined conversion in a template)
authorNathan Sidwell <nathan@codesourcery.com>
Tue, 31 May 2005 17:43:26 +0000 (17:43 +0000)
committerNathan Sidwell <nathan@gcc.gnu.org>
Tue, 31 May 2005 17:43:26 +0000 (17:43 +0000)
cp:
PR c++/21165
* init.c (integral_constant_value): Check the type of the
initializer, not the decl.
testsuite:
PR c++/21165
* g++.dg/template/init5.C: New.

From-SVN: r100402

gcc/cp/ChangeLog
gcc/cp/init.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/template/init5.C [new file with mode: 0644]

index ae4aca71f5f1fa00d57534c8a4864cf56202f29a..36f72dfc998b9f13c2644a0b622569fcb76c608b 100644 (file)
@@ -1,3 +1,9 @@
+2005-05-31  Nathan Sidwell  <nathan@codesourcery.com>
+
+       PR c++/21165
+       * init.c (integral_constant_value): Check the type of the
+       initializer, not the decl.
+
 2005-05-30  Mark Mitchell  <mark@codesourcery.com>
 
        PR c++/21784
index 99891cb2922effc58778cdff36dfa78159c3fbe0..7c8d9c6a8005faa15d32418ba0905fc5ae554781 100644 (file)
@@ -1573,7 +1573,7 @@ integral_constant_value (tree decl)
         && DECL_INITIAL (decl)
         && DECL_INITIAL (decl) != error_mark_node
         && TREE_TYPE (DECL_INITIAL (decl))
-        && INTEGRAL_OR_ENUMERATION_TYPE_P (TREE_TYPE (decl)))
+        && INTEGRAL_OR_ENUMERATION_TYPE_P (TREE_TYPE (DECL_INITIAL (decl))))
     decl = DECL_INITIAL (decl);
   return decl;
 }
index 57f8f913c02b114f3f994ddded3893ba4473893e..3d27673835d03fb58aa07fe37bcf0b833ffb3ea8 100644 (file)
@@ -1,3 +1,8 @@
+2005-05-31  Nathan Sidwell  <nathan@codesourcery.com>
+
+       PR c++/21165
+       * g++.dg/template/init5.C: New.
+
 2005-05-31  Paul Thomas  <pault@gcc.gnu.org>
 
        * gfortran.dg/char_initialiser_actual.f90:
diff --git a/gcc/testsuite/g++.dg/template/init5.C b/gcc/testsuite/g++.dg/template/init5.C
new file mode 100644 (file)
index 0000000..ab529be
--- /dev/null
@@ -0,0 +1,11 @@
+// Copyright (C) 2005 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 31 May 2005 <nathan@codesourcery.com>
+
+// PR 21165. ICE on valid
+// Origin:Volker Reichelt  reichelt@gcc.gnu.org
+
+template<typename T> bool foo()
+{
+    const int i = T();
+    return i > 0;
+}