]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/3416 (gcc-3.0 Internal compiler error in arg_assoc, at cp/decl2.c:4902)
authorNathan Sidwell <nathan@codesourcery.com>
Wed, 25 Jul 2001 09:38:26 +0000 (09:38 +0000)
committerNathan Sidwell <nathan@gcc.gnu.org>
Wed, 25 Jul 2001 09:38:26 +0000 (09:38 +0000)
cp:
PR c++/3416
* call.c (build_conditional_expr): Recheck args after
conversions.
* cp-tree.h (build_conditional_expr): Move to correct file.
* typeck.c (decay_conversion): Diagnose any unknown types
reaching here.
(build_binary_op): Don't do initial decay or default
conversions on overloaded functions.
(build_static_cast): Don't do a decay conversion here.
testsuite:
* g++.old-deja/g++.other/cond7.C: New test.

From-SVN: r44345

gcc/cp/ChangeLog
gcc/cp/call.c
gcc/cp/cp-tree.h
gcc/cp/typeck.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.old-deja/g++.other/cond7.C [new file with mode: 0644]

index 9d1844dabb52c4831388850c6668bea06b9f09f3..eb000083a11b68e338137c85d2f5a242950829ea 100644 (file)
@@ -1,3 +1,15 @@
+2001-07-25  Nathan Sidwell  <nathan@codesourcery.com>
+
+       PR c++/3416
+       * call.c (build_conditional_expr): Recheck args after
+       conversions.
+       * cp-tree.h (build_conditional_expr): Move to correct file.
+       * typeck.c (decay_conversion): Diagnose any unknown types
+       reaching here.
+       (build_binary_op): Don't do initial decay or default
+       conversions on overloaded functions.
+       (build_static_cast): Don't do a decay conversion here.
+
 2001-07-25  Nathan Sidwell  <nathan@codesourcery.com>
 
        PR c++/3543
index c8c524618c3227841b49bd879783a3ceef05b236..4be0920f2cafed9f11ca0172b5e8b737e33c8015 100644 (file)
@@ -3092,6 +3092,9 @@ build_conditional_expr (arg1, arg2, arg3)
     arg3 = decay_conversion (arg3);
   arg3_type = TREE_TYPE (arg3);
 
+  if (arg2 == error_mark_node || arg3 == error_mark_node)
+    return error_mark_node;
+  
   /* [expr.cond]
      
      After those conversions, one of the following shall hold:
index 4809acab51b5f34583b5b9b8a7f1e10374780faa..8a6b0ae90d942442afbafd68ff75080e3f7a836c 100644 (file)
@@ -3545,6 +3545,7 @@ extern int get_arglist_len_in_bytes               PARAMS ((tree));
 
 extern tree build_vfield_ref                   PARAMS ((tree, tree));
 extern tree build_scoped_method_call           PARAMS ((tree, tree, tree, tree));
+extern tree build_conditional_expr             PARAMS ((tree, tree, tree));
 extern tree build_addr_func                    PARAMS ((tree));
 extern tree build_call                         PARAMS ((tree, tree));
 extern tree build_method_call                  PARAMS ((tree, tree, tree, tree, int));
@@ -4305,7 +4306,6 @@ extern tree build_x_binary_op                     PARAMS ((enum tree_code, tree, tree));
 extern tree build_x_unary_op                   PARAMS ((enum tree_code, tree));
 extern tree unary_complex_lvalue               PARAMS ((enum tree_code, tree));
 extern tree build_x_conditional_expr           PARAMS ((tree, tree, tree));
-extern tree build_conditional_expr             PARAMS ((tree, tree, tree));
 extern tree build_x_compound_expr              PARAMS ((tree));
 extern tree build_compound_expr                        PARAMS ((tree));
 extern tree build_static_cast                  PARAMS ((tree, tree));
index a6ddcf269f765ac0d269911d9d4380f966aed76c..9043111786a75bb3e36a31968e42cefe9d40ac4f 100644 (file)
@@ -1729,6 +1729,12 @@ decay_conversion (exp)
   if (type == error_mark_node)
     return error_mark_node;
 
+  if (type_unknown_p (exp))
+    {
+      incomplete_type_error (exp, TREE_TYPE (exp));
+      return error_mark_node;
+    }
+  
   /* Constants can be used directly unless they're not loadable.  */
   if (TREE_CODE (exp) == CONST_DECL)
     exp = DECL_INITIAL (exp);
@@ -3365,17 +3371,24 @@ build_binary_op (code, orig_op0, orig_op1, convert_p)
   int common = 0;
 
   /* Apply default conversions.  */
+  op0 = orig_op0;
+  op1 = orig_op1;
+  
   if (code == TRUTH_AND_EXPR || code == TRUTH_ANDIF_EXPR
       || code == TRUTH_OR_EXPR || code == TRUTH_ORIF_EXPR
       || code == TRUTH_XOR_EXPR)
     {
-      op0 = decay_conversion (orig_op0);
-      op1 = decay_conversion (orig_op1);
+      if (!really_overloaded_fn (op0))
+       op0 = decay_conversion (op0);
+      if (!really_overloaded_fn (op1))
+       op1 = decay_conversion (op1);
     }
   else
     {
-      op0 = default_conversion (orig_op0);
-      op1 = default_conversion (orig_op1);
+      if (!really_overloaded_fn (op0))
+       op0 = default_conversion (op0);
+      if (!really_overloaded_fn (op1))
+       op1 = default_conversion (op1);
     }
 
   /* Strip NON_LVALUE_EXPRs, etc., since we aren't using as an lvalue.  */
@@ -5100,7 +5113,6 @@ build_static_cast (type, expr)
                                    build_tree_list (NULL_TREE, expr),
                                    TYPE_BINFO (type), LOOKUP_NORMAL)));
   
-  expr = decay_conversion (expr);
   intype = TREE_TYPE (expr);
 
   /* FIXME handle casting to array type.  */
index abf5ae4c5e279c14bef3ea0f83f62572436c18a4..2baa8c043a2a2f445ed2a0c1ce97b75984f9659d 100644 (file)
@@ -1,3 +1,7 @@
+2001-07-25  Nathan Sidwell  <nathan@codesourcery.com>
+
+       * g++.old-deja/g++.other/cond7.C: New test.
+
 2001-07-25  Nathan Sidwell  <nathan@codesourcery.com>
 
        * g++.old-deja/g++.other/optimize4.C: New test.
diff --git a/gcc/testsuite/g++.old-deja/g++.other/cond7.C b/gcc/testsuite/g++.old-deja/g++.other/cond7.C
new file mode 100644 (file)
index 0000000..49fa73c
--- /dev/null
@@ -0,0 +1,26 @@
+// Build don't link:
+// 
+// Copyright (C) 2001 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 24 Jul 2001 <nathan@codesourcery.com>
+
+// Bug 3416. We left some unchecked overloaded functions lying around.
+
+struct X
+{
+  void operator << (int);
+  void operator << (float);
+};
+
+void OVL1 (int);
+void OVL1 (float);
+
+void OVL2 (int);
+void OVL2 (float);
+
+X x;
+
+void foo (bool a)
+{
+  x << (a ? OVL1 : OVL2);      // ERROR - incomplete type
+  a ? OVL1 : OVL2;              // ERROR - incomplete type
+}