aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Henderson <rth@redhat.com>2002-06-16 17:26:56 -0700
committerRichard Henderson <rth@gcc.gnu.org>2002-06-16 17:26:56 -0700
commitfd852454b1cefd1a004cded6f5afd7332d5b6f81 (patch)
tree1c5ffe3dd3729a28523054a576d21e351f49d116
parent9d321f6caade85a66c564aa35213fa2739370f54 (diff)
downloadgcc-fd852454b1cefd1a004cded6f5afd7332d5b6f81.zip
gcc-fd852454b1cefd1a004cded6f5afd7332d5b6f81.tar.gz
gcc-fd852454b1cefd1a004cded6f5afd7332d5b6f81.tar.bz2
tree.c (cp_cannot_inline_tree_fn): Don't short-circuit test after template instantiation.
* tree.c (cp_cannot_inline_tree_fn): Don't short-circuit test after template instantiation. * g++.dg/opt/inline3.C: New. From-SVN: r54687
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/tree.c3
-rw-r--r--gcc/testsuite/g++.dg/opt/inline3.C40
3 files changed, 48 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 707ee6f..4da4bd4 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,11 @@
2002-06-16 Richard Henderson <rth@redhat.com>
+ PR opt/6793
+ * tree.c (cp_cannot_inline_tree_fn): Don't short-circuit test
+ after template instantiation.
+
+2002-06-16 Richard Henderson <rth@redhat.com>
+
* cp-tree.h, decl2.c (flag_ms_extensions): Move to c-common.
2002-06-15 Gabriel Dos Reis <gdr@codesourcery.com>
diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c
index 0752d7b..9c14696 100644
--- a/gcc/cp/tree.c
+++ b/gcc/cp/tree.c
@@ -2162,7 +2162,8 @@ cp_cannot_inline_tree_fn (fnp)
&& TI_PENDING_TEMPLATE_FLAG (DECL_TEMPLATE_INFO (fn)))
{
fn = *fnp = instantiate_decl (fn, /*defer_ok=*/0);
- return TI_PENDING_TEMPLATE_FLAG (DECL_TEMPLATE_INFO (fn));
+ if (TI_PENDING_TEMPLATE_FLAG (DECL_TEMPLATE_INFO (fn)))
+ return 1;
}
if (varargs_function_p (fn))
diff --git a/gcc/testsuite/g++.dg/opt/inline3.C b/gcc/testsuite/g++.dg/opt/inline3.C
new file mode 100644
index 0000000..7199de0
--- /dev/null
+++ b/gcc/testsuite/g++.dg/opt/inline3.C
@@ -0,0 +1,40 @@
+// PR opt/6793
+// We failed to supress inlining of a varargs function when it's a template.
+// { dg-do compile }
+// { dg-options "-O3" }
+
+#include <stdarg.h>
+
+typedef __SIZE_TYPE__ size_t;
+
+template < class Type > class VectorNd
+{
+ size_t size;
+ Type *data;
+ public:
+
+ VectorNd (size_t _size, size_t count, ...)
+ : size (_size)
+ {
+ data = new Type[size];
+
+ va_list ap;
+
+ va_start (ap, count);
+
+ for (size_t i = 0; i < count; i++)
+ data[i] = va_arg (ap, Type);
+
+ va_end (ap);
+ }
+
+ ~VectorNd ()
+ {
+ delete [] data;
+ }
+};
+
+int main ()
+{
+ VectorNd <double> vector (3, 3, 1.0, 2.0, 3.0);
+}