* Patch for Gabriel's member template bug
@ 1997-12-05 14:00 Mark Mitchell
0 siblings, 0 replies; only message in thread
From: Mark Mitchell @ 1997-12-05 14:00 UTC (permalink / raw)
To: Jason Merrill, Gabriel Dos Reis, egcs
Here's a patch for the problem Gabriel reported on 11/20. A boiled
down version of the test case is:
template<unsigned int n> struct PartialDotProduct {
template<class T>
static T Expand(T* a, T* b) { return T(); }
};
const int N = 10;
template<class In1, class In2>
void
dot(In1 f1, In2 f2)
{
PartialDotProduct<N>::Expand(f1, f2);
}
int main()
{
double a[N], b[N];
dot(&a[0], &b[0]);
}
The fix cannot possibly cause any additional cases to fail
since it simply removes a (spurious) internal error.
--
Mark Mitchell mmitchell@usa.net
Stanford University http://www.stanford.edu
1997-12-05 Mark Mitchell <mmitchell@usa.net>
* method.c (build_overload_int): Remove in_template parameter.
(build_overload_value): Likewise.
(build_template_parm_names): Don't pass it anymore.
Index: gcc/cp/method.c
===================================================================
RCS file: /home/mitchell/Repository/egcs/gcc/cp/method.c,v
retrieving revision 1.2
diff -c -p -r1.2 method.c
*** method.c 1997/12/02 23:35:02 1.2
--- method.c 1997/12/05 19:16:08
*************** static void dicat PROTO((HOST_WIDE_INT,
*** 63,72 ****
static void flush_repeats PROTO((tree));
static void build_overload_identifier PROTO((tree));
static void build_overload_nested_name PROTO((tree));
! static void build_overload_int PROTO((tree, int));
static void build_overload_identifier PROTO((tree));
static void build_qualified_name PROTO((tree));
! static void build_overload_value PROTO((tree, tree, int));
static char *thunk_printable_name PROTO((tree));
static void do_build_assign_ref PROTO((tree));
static void do_build_copy_constructor PROTO((tree));
--- 63,72 ----
static void flush_repeats PROTO((tree));
static void build_overload_identifier PROTO((tree));
static void build_overload_nested_name PROTO((tree));
! static void build_overload_int PROTO((tree));
static void build_overload_identifier PROTO((tree));
static void build_qualified_name PROTO((tree));
! static void build_overload_value PROTO((tree, tree));
static char *thunk_printable_name PROTO((tree));
static void do_build_assign_ref PROTO((tree));
static void do_build_copy_constructor PROTO((tree));
*************** build_underscore_int (i)
*** 431,444 ****
/* Encoding for an INTEGER_CST value. */
static void
! build_overload_int (value, in_template)
tree value;
- int in_template;
{
! if (in_template && TREE_CODE (value) != INTEGER_CST)
/* We don't ever want this output, but it's inconvenient not to
be able to build the string. This should cause assembler
! errors we'll notice. */
{
static int n;
sprintf (digit_buffer, " *%d", n++);
--- 431,445 ----
/* Encoding for an INTEGER_CST value. */
static void
! build_overload_int (value)
tree value;
{
! if (TREE_CODE (value) != INTEGER_CST)
/* We don't ever want this output, but it's inconvenient not to
be able to build the string. This should cause assembler
! errors we'll notice. We can end up here when processing a
! template declaration, or when instantiating a class with member
! templates. */
{
static int n;
sprintf (digit_buffer, " *%d", n++);
*************** build_overload_int (value, in_template)
*** 463,471 ****
}
static void
! build_overload_value (type, value, in_template)
tree type, value;
- int in_template;
{
while (TREE_CODE (value) == NON_LVALUE_EXPR
|| TREE_CODE (value) == NOP_EXPR)
--- 464,471 ----
}
static void
! build_overload_value (type, value)
tree type, value;
{
while (TREE_CODE (value) == NON_LVALUE_EXPR
|| TREE_CODE (value) == NOP_EXPR)
*************** build_overload_value (type, value, in_te
*** 509,515 ****
case ENUMERAL_TYPE:
case BOOLEAN_TYPE:
{
! build_overload_int (value, in_template);
numeric_output_need_bar = 1;
return;
}
--- 509,515 ----
case ENUMERAL_TYPE:
case BOOLEAN_TYPE:
{
! build_overload_int (value);
numeric_output_need_bar = 1;
return;
}
*************** build_overload_value (type, value, in_te
*** 595,603 ****
if (TREE_CODE (a1) == INTEGER_CST
&& TREE_CODE (a2) == INTEGER_CST)
{
! build_overload_int (a1, in_template);
OB_PUTC ('_');
! build_overload_int (a2, in_template);
OB_PUTC ('_');
if (TREE_CODE (a3) == ADDR_EXPR)
{
--- 595,603 ----
if (TREE_CODE (a1) == INTEGER_CST
&& TREE_CODE (a2) == INTEGER_CST)
{
! build_overload_int (a1);
OB_PUTC ('_');
! build_overload_int (a2);
OB_PUTC ('_');
if (TREE_CODE (a3) == ADDR_EXPR)
{
*************** build_overload_value (type, value, in_te
*** 612,618 ****
else if (TREE_CODE (a3) == INTEGER_CST)
{
OB_PUTC ('i');
! build_overload_int (a3, in_template);
numeric_output_need_bar = 1;
return;
}
--- 612,618 ----
else if (TREE_CODE (a3) == INTEGER_CST)
{
OB_PUTC ('i');
! build_overload_int (a3);
numeric_output_need_bar = 1;
return;
}
*************** build_overload_value (type, value, in_te
*** 624,630 ****
if (TREE_CODE (value) == INTEGER_CST
|| TREE_CODE (value) == TEMPLATE_CONST_PARM)
{
! build_overload_int (value, in_template);
numeric_output_need_bar = 1;
return;
}
--- 624,630 ----
if (TREE_CODE (value) == INTEGER_CST
|| TREE_CODE (value) == TEMPLATE_CONST_PARM)
{
! build_overload_int (value);
numeric_output_need_bar = 1;
return;
}
*************** build_template_parm_names (parmlist, arg
*** 689,695 ****
TREE_VEC_LENGTH (arglist), NULL_TREE);
/* It's a PARM_DECL. */
build_overload_name (TREE_TYPE (parm), 0, 0);
! build_overload_value (parm, arg, uses_template_parms (arglist));
}
}
}
--- 689,695 ----
TREE_VEC_LENGTH (arglist), NULL_TREE);
/* It's a PARM_DECL. */
build_overload_name (TREE_TYPE (parm), 0, 0);
! build_overload_value (parm, arg);
}
}
}
Index: gcc/testsuite/g++.old-deja/g++.pt/memtemp63.C
===================================================================
RCS file: memtemp63.C
diff -N memtemp63.C
*** /dev/null Mon Dec 31 20:00:00 1979
--- memtemp63.C Fri Dec 5 11:18:46 1997
***************
*** 0 ****
--- 1,23 ----
+ // Build don't link:
+
+ template<unsigned int n> struct PartialDotProduct {
+ template<class T>
+ static T Expand(T* a, T* b) { return T(); }
+ };
+
+ const int N = 10;
+
+ template<class In1, class In2>
+ void
+ dot(In1 f1, In2 f2)
+ {
+ PartialDotProduct<N>::Expand(f1, f2);
+
+ }
+
+ int main()
+ {
+ double a[N], b[N];
+
+ dot(&a[0], &b[0]);
+ }
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~1997-12-05 14:00 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-12-05 14:00 Patch for Gabriel's member template bug Mark Mitchell
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).