aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMark Mitchell <mark@codesourcery.com>2004-10-28 05:17:14 +0000
committerMark Mitchell <mmitchel@gcc.gnu.org>2004-10-28 05:17:14 +0000
commit391c4bc5af5c7fc7aa2a6fcbdf90704fbf3f0300 (patch)
tree7dd36dec39291468ce49f6128a24f9fb8a5593fa /gcc
parent0da34ce409cd62755c3546f40693ee596cffddb2 (diff)
downloadgcc-391c4bc5af5c7fc7aa2a6fcbdf90704fbf3f0300.zip
gcc-391c4bc5af5c7fc7aa2a6fcbdf90704fbf3f0300.tar.gz
gcc-391c4bc5af5c7fc7aa2a6fcbdf90704fbf3f0300.tar.bz2
re PR c++/17435 (Binding a temporary of derived type to reference of base)
PR c++/17435 * call.c (convert_like_real): Fix formatting. (initialize_reference): When binding a temporary to a base class, ensure that the nominal copy made is to the derived class, not the base class. PR c++/18140 * parser.c (cp_parser_next_token_ends_template_argument_p): Do not include ">>". PR c++/17435 * g++.dg/init/ref12.C: New test. PR c++/18140 * g++.dg/template/shift1.C: New test. * g++.dg/template/error10.C: Adjust error markers. From-SVN: r89738
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog12
-rw-r--r--gcc/cp/call.c9
-rw-r--r--gcc/cp/parser.c7
-rw-r--r--gcc/testsuite/ChangeLog9
-rw-r--r--gcc/testsuite/g++.dg/init/ref12.C29
-rw-r--r--gcc/testsuite/g++.dg/template/error10.C4
-rw-r--r--gcc/testsuite/g++.dg/template/shift1.C10
7 files changed, 71 insertions, 9 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index a6aa65e..d4df8e5 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,15 @@
+2004-10-27 Mark Mitchell <mark@codesourcery.com>
+
+ PR c++/17435
+ * call.c (convert_like_real): Fix formatting.
+ (initialize_reference): When binding a temporary to a base class,
+ ensure that the nominal copy made is to the derived class, not the
+ base class.
+
+ PR c++/18140
+ * parser.c (cp_parser_next_token_ends_template_argument_p): Do not
+ include ">>".
+
2004-10-27 Andrew Pinski <pinskia@physics.uc.edu>
* decl.c: Move the q after the %.
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index aedc927..9ff5b7c 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -4239,7 +4239,7 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum,
expr = decl_constant_value (expr);
if (convs->check_copy_constructor_p)
check_constructor_callable (totype, expr);
- return expr;
+ return expr;
case ck_ambig:
/* Call build_user_type_conversion again for the error. */
return build_user_type_conversion
@@ -6467,7 +6467,7 @@ initialize_reference (tree type, tree expr, tree decl, tree *cleanup)
conv = conv->u.next;
/* If the next conversion is a BASE_CONV, skip that too -- but
remember that the conversion was required. */
- if (conv->kind == ck_base && conv->need_temporary_p)
+ if (conv->kind == ck_base)
{
if (conv->check_copy_constructor_p)
check_constructor_callable (TREE_TYPE (expr), expr);
@@ -6537,6 +6537,11 @@ initialize_reference (tree type, tree expr, tree decl, tree *cleanup)
}
/* Use its address to initialize the reference variable. */
expr = build_address (var);
+ if (base_conv_type)
+ expr = convert_to_base (expr,
+ build_pointer_type (base_conv_type),
+ /*check_access=*/true,
+ /*nonnull=*/true);
expr = build2 (COMPOUND_EXPR, TREE_TYPE (expr), init, expr);
}
else
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 4cfcf73..ccb1ac1 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -15474,9 +15474,7 @@ cp_parser_next_token_starts_class_definition_p (cp_parser *parser)
}
/* Returns TRUE iff the next token is the "," or ">" ending a
- template-argument. ">>" is also accepted (after the full
- argument was parsed) because it's probably a typo for "> >",
- and there is a specific diagnostic for this. */
+ template-argument. */
static bool
cp_parser_next_token_ends_template_argument_p (cp_parser *parser)
@@ -15484,8 +15482,7 @@ cp_parser_next_token_ends_template_argument_p (cp_parser *parser)
cp_token *token;
token = cp_lexer_peek_token (parser->lexer);
- return (token->type == CPP_COMMA || token->type == CPP_GREATER
- || token->type == CPP_RSHIFT);
+ return (token->type == CPP_COMMA || token->type == CPP_GREATER);
}
/* Returns TRUE iff the n-th token is a ">", or the n-th is a "[" and the
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 91333ce..a297edb 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,12 @@
+2004-10-27 Mark Mitchell <mark@codesourcery.com>
+
+ PR c++/17435
+ * g++.dg/init/ref12.C: New test.
+
+ PR c++/18140
+ * g++.dg/template/shift1.C: New test.
+ * g++.dg/template/error10.C: Adjust error markers.
+
2004-10-27 Andrew Pinski <pinskia@physics.uc.edu>
PR tree-opt/17529
diff --git a/gcc/testsuite/g++.dg/init/ref12.C b/gcc/testsuite/g++.dg/init/ref12.C
new file mode 100644
index 0000000..c5f27ae
--- /dev/null
+++ b/gcc/testsuite/g++.dg/init/ref12.C
@@ -0,0 +1,29 @@
+// PR c++/17435
+
+extern "C" void abort ();
+
+bool ok;
+
+struct A
+{
+ void func() const
+ {
+ ok = 1;
+ }
+
+ ~A()
+ {
+ if (!ok)
+ abort ();
+ }
+};
+
+struct B : public A
+{
+};
+
+int main()
+{
+ A const& r1 = B();
+ r1.func();
+}
diff --git a/gcc/testsuite/g++.dg/template/error10.C b/gcc/testsuite/g++.dg/template/error10.C
index ccb577d..dcb4f3e 100644
--- a/gcc/testsuite/g++.dg/template/error10.C
+++ b/gcc/testsuite/g++.dg/template/error10.C
@@ -66,5 +66,5 @@ struct K {};
void KFunc(void);
-A<K<&KFunc>> k1; // { dg-error "should be '> >' within" }
-K<&KFunc>> k2; // { dg-error "spurious '>>'" }
+A<K<&KFunc>> k1; // { dg-error "" }
+K<&KFunc>> k2; // { dg-error "" }
diff --git a/gcc/testsuite/g++.dg/template/shift1.C b/gcc/testsuite/g++.dg/template/shift1.C
new file mode 100644
index 0000000..22cb0de
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/shift1.C
@@ -0,0 +1,10 @@
+// PR c++/18140
+
+template <int N> struct IntHolder {
+ static const int value = N;
+};
+
+template <int N, int S> struct ShrIntHolder {
+ static const int value = IntHolder< N>>S >::value;
+};
+