aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorMark Mitchell <mark@codesourcery.com>2004-01-26 03:13:49 +0000
committerMark Mitchell <mmitchel@gcc.gnu.org>2004-01-26 03:13:49 +0000
commitb7c707d1d95fbd6ecc91d7b653c4e607d307cb02 (patch)
tree0c78d892037be972339a54108a5239aaec45f49e /gcc/cp
parent9c3602e40ffa8b11bbee42a2d4ee81dbd8759fd8 (diff)
downloadgcc-b7c707d1d95fbd6ecc91d7b653c4e607d307cb02.zip
gcc-b7c707d1d95fbd6ecc91d7b653c4e607d307cb02.tar.gz
gcc-b7c707d1d95fbd6ecc91d7b653c4e607d307cb02.tar.bz2
re PR c++/13833 (Conversion problem in template function)
PR c++/13833 * call.c (build_over_call): Do not convert arguments when processing a template. * pt.c (build_non_dependent_expr): Do not build a NON_DEPENDENT_EXPR for arithmetic constants. PR c++/13833 * g++.dg/template/cond3.C: New test. From-SVN: r76616
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog8
-rw-r--r--gcc/cp/call.c15
-rw-r--r--gcc/cp/pt.c4
3 files changed, 27 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 5171c70..a463df6 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,11 @@
+2004-01-25 Mark Mitchell <mark@codesourcery.com>
+
+ PR c++/13833
+ * call.c (build_over_call): Do not convert arguments when
+ processing a template.
+ * pt.c (build_non_dependent_expr): Do not build a
+ NON_DEPENDENT_EXPR for arithmetic constants.
+
2004-01-25 Giovanni Bajo <giovannibajo@gcc.gnu.org>
PR c++/13810
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index 5fefefe..ea494c7 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -4306,6 +4306,21 @@ build_over_call (struct z_candidate *cand, int flags)
int i = 0;
int is_method = 0;
+ /* In a template, there is no need to perform all of the work that
+ is normally done. We are only interested in the type of the call
+ expression, i.e., the return type of the function. Any semantic
+ errors will be deferred until the template is instantiated. */
+ if (processing_template_decl)
+ {
+ tree expr;
+ tree return_type;
+ return_type = TREE_TYPE (TREE_TYPE (fn));
+ expr = build (CALL_EXPR, return_type, fn, args);
+ if (!VOID_TYPE_P (return_type))
+ require_complete_type (return_type);
+ return convert_from_reference (expr);
+ }
+
/* Give any warnings we noticed during overload resolution. */
if (cand->warnings)
for (val = cand->warnings; val; val = TREE_CHAIN (val))
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 2178e90..a9ab858 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -11993,6 +11993,10 @@ build_non_dependent_expr (tree expr)
cannot be used to initialize a "char *". */
if (TREE_CODE (expr) == STRING_CST)
return expr;
+ /* Preserve arithmetic constants, as an optimization -- there is no
+ reason to create a new node. */
+ if (TREE_CODE (expr) == INTEGER_CST || TREE_CODE (expr) == REAL_CST)
+ return expr;
if (TREE_CODE (expr) == COND_EXPR)
return build (COND_EXPR,