OSDN Git Service

/cp
authorpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 30 Jun 2010 20:46:46 +0000 (20:46 +0000)
committerpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 30 Jun 2010 20:46:46 +0000 (20:46 +0000)
2010-06-30  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/44628
* typeck.c (cp_build_unary_op): Early return error_mark_node when
arg is NULL_TREE too.
* call.c (convert_class_to_reference): Return error_mark_node when
expr is NULL_TREE.

/testsuite
2010-06-30  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/44628
* g++.dg/template/crash100.C: New.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@161639 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/call.c
gcc/cp/typeck.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/template/crash100.C [new file with mode: 0644]

index f72e7a6..3c6268d 100644 (file)
@@ -1,6 +1,14 @@
+2010-06-30  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/44628
+       * typeck.c (cp_build_unary_op): Early return error_mark_node when
+       arg is NULL_TREE too.
+       * call.c (convert_class_to_reference): Return error_mark_node when
+       expr is NULL_TREE.
+
 2010-06-30  Michael Matz  <matz@suse.de>
 
-       * repo.c ((finish_repo): Fix typo.
+       * repo.c (finish_repo): Fix typo.
 
 2010-06-30  Nathan Froyd  <froydnj@codesourcery.com>
 
@@ -17,7 +25,7 @@
        * tree.c: Include gimple.h. Do not include tree-flow.h
        * decl.c: Do not include tree-flow.h
        * Make-lang.in: Adjust dependencies.
-       
+
 2010-06-29  Nathan Froyd  <froydnj@codesourcery.com>
 
        * decl.c (incomplete_var): Declare.  Declare VECs containing them.
index 7e632d0..d03ecb1 100644 (file)
@@ -1040,6 +1040,9 @@ convert_class_to_reference (tree reference_type, tree s, tree expr, int flags)
   struct z_candidate *cand;
   bool any_viable_p;
 
+  if (!expr)
+    return NULL;
+
   conversions = lookup_conversions (s, /*lookup_template_convs_p=*/true);
   if (!conversions)
     return NULL;
index 4383ef5..20345b5 100644 (file)
@@ -4781,7 +4781,7 @@ cp_build_unary_op (enum tree_code code, tree xarg, int noconvert,
   tree val;
   const char *invalid_op_diag;
 
-  if (error_operand_p (arg))
+  if (!arg || error_operand_p (arg))
     return error_mark_node;
 
   if ((invalid_op_diag
index d9e9a40..474e096 100644 (file)
@@ -1,3 +1,8 @@
+2010-06-30  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/44628
+       * g++.dg/template/crash100.C: New.
+
 2010-06-30  Jan Hubicka  <jh@suse.cz>
 
        * gcc.dg/tree-ssa/ipa-split-4.c: New testcase.
diff --git a/gcc/testsuite/g++.dg/template/crash100.C b/gcc/testsuite/g++.dg/template/crash100.C
new file mode 100644 (file)
index 0000000..c67ae2e
--- /dev/null
@@ -0,0 +1,24 @@
+// PR c++/44628
+
+template <typename T>
+class Temp
+{
+  int Val;
+  public:
+  operator T&(void)  { return Val; }
+
+  virtual T& operator=(T a ) // { dg-error "overriding" }
+  {
+    Val = a;
+    return Val;
+  }
+};
+
+class Int : public Temp<int>
+{
+  public:
+  Int& operator=(int a) // { dg-error "conflicting return type" }
+  {
+    return (*this);
+  }
+};