OSDN Git Service

PR c++/43790
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 27 Apr 2010 20:08:47 +0000 (20:08 +0000)
committerMasaki Muranaka <monaka@monami-software.com>
Sun, 23 May 2010 04:52:20 +0000 (13:52 +0900)
* tree.c (cv_unqualified): Handle error_mark_node.

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

gcc/cp/ChangeLog
gcc/cp/tree.c
gcc/testsuite/ChangeLog

index f7456bf..68c6b49 100644 (file)
@@ -1,5 +1,8 @@
 2010-04-27  Jason Merrill  <jason@redhat.com>
 
+       PR c++/43790
+       * tree.c (cv_unqualified): Handle error_mark_node.
+
        PR c++/41468
        * call.c (convert_like_real) [ck_ambig]: Just return error_mark_node
        if we don't want errors.
index 40a0c52..0abc12c 100644 (file)
@@ -27,6 +27,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "tree.h"
 #include "cp-tree.h"
 #include "flags.h"
+#include "real.h"
 #include "rtl.h"
 #include "toplev.h"
 #include "insn-config.h"
@@ -550,8 +551,6 @@ rvalue (tree expr)
   if (error_operand_p (expr))
     return expr;
 
-  expr = mark_rvalue_use (expr);
-
   /* [basic.lval]
 
      Non-class rvalues always have cv-unqualified types.  */
@@ -864,22 +863,15 @@ cp_build_qualified_type_real (tree type,
     }
 
   /* A reference or method type shall not be cv-qualified.
-     [dcl.ref], [dcl.fct].  This used to be an error, but as of DR 295
-     (in CD1) we always ignore extra cv-quals on functions.  */
+     [dcl.ref], [dcl.fct]  */
   if (type_quals & (TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE)
       && (TREE_CODE (type) == REFERENCE_TYPE
-         || TREE_CODE (type) == FUNCTION_TYPE
          || TREE_CODE (type) == METHOD_TYPE))
     {
-      if (TREE_CODE (type) == REFERENCE_TYPE)
-       bad_quals |= type_quals & (TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE);
+      bad_quals |= type_quals & (TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE);
       type_quals &= ~(TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE);
     }
 
-  /* But preserve any function-cv-quals on a FUNCTION_TYPE.  */
-  if (TREE_CODE (type) == FUNCTION_TYPE)
-    type_quals |= type_memfn_quals (type);
-
   /* A restrict-qualified type must be a pointer (or reference)
      to object or incomplete type. */
   if ((type_quals & TYPE_QUAL_RESTRICT)
@@ -891,16 +883,24 @@ cp_build_qualified_type_real (tree type,
       type_quals &= ~TYPE_QUAL_RESTRICT;
     }
 
-  if (bad_quals == TYPE_UNQUALIFIED
-      || (complain & tf_ignore_bad_quals))
+  if (bad_quals == TYPE_UNQUALIFIED)
     /*OK*/;
-  else if (!(complain & tf_error))
+  else if (!(complain & (tf_error | tf_ignore_bad_quals)))
     return error_mark_node;
   else
     {
-      tree bad_type = build_qualified_type (ptr_type_node, bad_quals);
-      error ("%qV qualifiers cannot be applied to %qT",
-            bad_type, type);
+      if (complain & tf_ignore_bad_quals)
+       /* We're not going to warn about constifying things that can't
+          be constified.  */
+       bad_quals &= ~TYPE_QUAL_CONST;
+      if (bad_quals)
+       {
+         tree bad_type = build_qualified_type (ptr_type_node, bad_quals);
+
+         if (!(complain & tf_ignore_bad_quals))
+           error ("%qV qualifiers cannot be applied to %qT",
+                  bad_type, type);
+       }
     }
 
   /* Retrieve (or create) the appropriately qualified variant.  */
@@ -939,7 +939,7 @@ cv_unqualified (tree type)
   if (type == error_mark_node)
     return type;
 
-  quals = cp_type_quals (type);
+  quals = TYPE_QUALS (type);
   quals &= ~(TYPE_QUAL_CONST|TYPE_QUAL_VOLATILE);
   return cp_build_qualified_type (type, quals);
 }
@@ -1036,11 +1036,8 @@ strip_typedefs (tree t)
                                          TREE_CHAIN (arg_types));
          }
        else
-         {
            result = build_function_type (type,
                                          arg_types);
-           result = apply_memfn_quals (result, type_memfn_quals (t));
-         }
 
        if (TYPE_RAISES_EXCEPTIONS (t))
          result = build_exception_variant (result,
@@ -1355,7 +1352,7 @@ really_overloaded_fn (tree x)
 }
 
 tree
-get_fns (tree from)
+get_first_fn (tree from)
 {
   gcc_assert (is_overloaded_fn (from));
   /* A baselink is also considered an overloaded function.  */
@@ -1366,13 +1363,7 @@ get_fns (tree from)
     from = BASELINK_FUNCTIONS (from);
   if (TREE_CODE (from) == TEMPLATE_ID_EXPR)
     from = TREE_OPERAND (from, 0);
-  return from;
-}
-
-tree
-get_first_fn (tree from)
-{
-  return OVL_CURRENT (get_fns (from));
+  return OVL_CURRENT (from);
 }
 
 /* Return a new OVL node, concatenating it with the old one.  */
@@ -1906,9 +1897,9 @@ build_min_non_dep (enum tree_code code, tree non_dep, ...)
   return t;
 }
 
-/* Similar to `build_nt_call_vec', but for template definitions of
-   non-dependent expressions. NON_DEP is the non-dependent expression
-   that has been built.  */
+/* Similar to `build_call_list', but for template definitions of non-dependent
+   expressions. NON_DEP is the non-dependent expression that has been
+   built.  */
 
 tree
 build_min_non_dep_call_vec (tree non_dep, tree fn, VEC(tree,gc) *argvec)
@@ -2302,11 +2293,11 @@ maybe_dummy_object (tree type, tree* binfop)
 {
   tree decl, context;
   tree binfo;
-  tree current = current_nonlambda_class_type ();
 
-  if (current
-      && (binfo = lookup_base (current, type, ba_any, NULL)))
-    context = current;
+  if (current_class_type
+      && (binfo = lookup_base (current_class_type, type,
+                              ba_unique | ba_quiet, NULL)))
+    context = current_class_type;
   else
     {
       /* Reference from a nested class member function.  */
@@ -2324,13 +2315,6 @@ maybe_dummy_object (tree type, tree* binfop)
       && same_type_p (TYPE_MAIN_VARIANT (TREE_TYPE (current_class_ref)),
                      current_class_type))
     decl = current_class_ref;
-  else if (current != current_class_type
-          && context == nonlambda_method_basetype ())
-    /* In a lambda, need to go through 'this' capture.  */
-    decl = (cp_build_indirect_ref
-           ((lambda_expr_this_capture
-             (CLASSTYPE_LAMBDA_EXPR (current_class_type))),
-            RO_NULL, tf_warning_or_error));
   else
     decl = build_dummy_object (context);
 
index c48c0fe..3a32098 100644 (file)
@@ -1,5 +1,7 @@
 2010-04-27  Jason Merrill  <jason@redhat.com>
 
+       * g++.dg/cpp0x/lambda/lambda-ice1.C: New.
+
        PR c++/41468
        * g++.dg/template/sfinae17.C: New.
        * g++.dg/template/sfinae18.C: New.