aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@codesourcery.com>2002-01-02 11:29:15 +0000
committerNathan Sidwell <nathan@gcc.gnu.org>2002-01-02 11:29:15 +0000
commit903c623438e8f4ce15639fffed80f9ced73a8bf7 (patch)
tree0a2878924eb6d120753fa4ffd96b1754db925d14
parent477558bf39db7da00236fc414e0ac53a5712f577 (diff)
downloadgcc-903c623438e8f4ce15639fffed80f9ced73a8bf7.zip
gcc-903c623438e8f4ce15639fffed80f9ced73a8bf7.tar.gz
gcc-903c623438e8f4ce15639fffed80f9ced73a8bf7.tar.bz2
re PR c++/5132 (NaN = 0.0 * HUGE_VAL fails to compile in templates)
cp: PR c++/5132 * decl2.c (reparse_absdcl_as_casts): Don't digest_init if we are processing a template decl. testsuite: * g++.dg/template/ctor1.C: New test. From-SVN: r48464
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/decl2.c16
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/g++.dg/template/ctor1.C22
4 files changed, 42 insertions, 6 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index beaf19a..a6ecc50 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,11 @@
2002-01-02 Nathan Sidwell <nathan@codesourcery.com>
+ PR c++/5132
+ * decl2.c (reparse_absdcl_as_casts): Don't digest_init if we
+ are processing a template decl.
+
+2002-01-02 Nathan Sidwell <nathan@codesourcery.com>
+
PR c++/5116, c++/764
* call.c (build_new_op): Make sure template class operands are
instantiated. Simplify arglist construction.
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index cde4e69..401ccbf 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -1,6 +1,6 @@
/* Process declarations and variables for C compiler.
Copyright (C) 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
- 1999, 2000, 2001 Free Software Foundation, Inc.
+ 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
Hacked by Michael Tiemann (tiemann@cygnus.com)
This file is part of GNU CC.
@@ -3622,12 +3622,16 @@ reparse_absdcl_as_casts (decl, expr)
type = groktypename (TREE_VALUE (CALL_DECLARATOR_PARMS (decl)));
decl = TREE_OPERAND (decl, 0);
- expr = digest_init (type, expr, (tree *) 0);
- if (TREE_CODE (type) == ARRAY_TYPE && !COMPLETE_TYPE_P (type))
+ if (processing_template_decl)
+ expr = build_min (CONSTRUCTOR, type, decl, CONSTRUCTOR_ELTS (expr));
+ else
{
- int failure = complete_array_type (type, expr, 1);
- if (failure)
- my_friendly_abort (78);
+ expr = digest_init (type, expr, (tree *) 0);
+ if (TREE_CODE (type) == ARRAY_TYPE && !COMPLETE_TYPE_P (type))
+ {
+ int failure = complete_array_type (type, expr, 1);
+ my_friendly_assert (!failure, 78);
+ }
}
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index dc7029d..1e0e603 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,9 @@
2002-01-02 Nathan Sidwell <nathan@codesourcery.com>
+ * g++.dg/template/ctor1.C: New test.
+
+2002-01-02 Nathan Sidwell <nathan@codesourcery.com>
+
* g++.dg/template/friend2.C: New test.
2002-01-01 Hans-Peter Nilsson <hp@bitrange.com>
diff --git a/gcc/testsuite/g++.dg/template/ctor1.C b/gcc/testsuite/g++.dg/template/ctor1.C
new file mode 100644
index 0000000..ceae740
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/ctor1.C
@@ -0,0 +1,22 @@
+// { dg-do compile }
+
+// Copyright (C) 2001 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 31 Dec 2001 <nathan@codesourcery.com>
+
+// PR 5132. ICE on struct constructors in templates.
+
+// snippets from bits/huge_val.h
+
+#define __HUGE_VAL_bytes { 0, 0, 0, 0, 0, 0, 0xf0, 0x7f }
+#define __huge_val_t union { unsigned char __c[8]; double __d; }
+#define HUGE_VAL (__extension__ \
+ ((__huge_val_t) { __c: __HUGE_VAL_bytes }).__d)
+
+void foo( const int&) {
+ HUGE_VAL; // no problem here
+}
+
+template <class F>
+void Tfoo( const F&) {
+ HUGE_VAL; // g++ fails here
+}