]> gcc.gnu.org Git - gcc.git/commitdiff
re PR c++/69257 (g++ ICE in "create_tmp_var" on invalid inline-asm)
authorJason Merrill <jason@redhat.com>
Fri, 15 Jan 2016 15:57:07 +0000 (10:57 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Fri, 15 Jan 2016 15:57:07 +0000 (10:57 -0500)
PR c++/69257
* typeck.c (decay_conversion): Don't call mark_rvalue_use for
array/function-to-pointer conversion.  Call
complete_type_or_maybe_complain for lvalue-to-rvalue conversion.
* call.c (convert_like_real): Print call context if
decay_conversion errors.

From-SVN: r232436

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

index 92925a3ecb02b21b0b0d712e96cdc83da5df1a13..028088400fcdfe0ae02661f8102aadb37f451041 100644 (file)
@@ -1,3 +1,12 @@
+2016-01-15  Jason Merrill  <jason@redhat.com>
+
+       PR c++/69257
+       * typeck.c (decay_conversion): Don't call mark_rvalue_use for
+       array/function-to-pointer conversion.  Call
+       complete_type_or_maybe_complain for lvalue-to-rvalue conversion.
+       * call.c (convert_like_real): Print call context if
+       decay_conversion errors.
+
 2016-01-14  Tom de Vries  <tom@codesourcery.com>
 
        PR tree-optimization/68773
index f3f95ef13acab5463b2cf0986c6e0a01ba733515..c05170a055749f467d2d480d241a9711bd5c9232 100644 (file)
@@ -6542,7 +6542,16 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum,
     case ck_rvalue:
       expr = decay_conversion (expr, complain);
       if (expr == error_mark_node)
-       return error_mark_node;
+       {
+         if (complain)
+           {
+             maybe_print_user_conv_context (convs);
+             if (fn)
+               inform (DECL_SOURCE_LOCATION (fn),
+                       "  initializing argument %P of %qD", argnum, fn);
+           }
+         return error_mark_node;
+       }
 
       if (! MAYBE_CLASS_TYPE_P (totype))
        return expr;
index 94267b67f961c009832c41a6da3d47f916cd4c08..0503c6f0c738e027d86cc1e7a240ab549a8320d7 100644 (file)
@@ -1909,11 +1909,10 @@ unlowered_expr_type (const_tree exp)
 
 /* Perform the conversions in [expr] that apply when an lvalue appears
    in an rvalue context: the lvalue-to-rvalue, array-to-pointer, and
-   function-to-pointer conversions.  In addition, manifest constants
-   are replaced by their values, and bitfield references are converted
-   to their declared types. Note that this function does not perform the
-   lvalue-to-rvalue conversion for class types. If you need that conversion
-   to for class types, then you probably need to use force_rvalue.
+   function-to-pointer conversions.  In addition, bitfield references are
+   converted to their declared types. Note that this function does not perform
+   the lvalue-to-rvalue conversion for class types. If you need that conversion
+   for class types, then you probably need to use force_rvalue.
 
    Although the returned value is being used as an rvalue, this
    function does not wrap the returned expression in a
@@ -1933,8 +1932,6 @@ decay_conversion (tree exp,
   if (type == error_mark_node)
     return error_mark_node;
 
-  exp = mark_rvalue_use (exp, loc, reject_builtin);
-
   exp = resolve_nondeduced_context (exp);
   if (type_unknown_p (exp))
     {
@@ -1962,12 +1959,19 @@ decay_conversion (tree exp,
   if (invalid_nonstatic_memfn_p (loc, exp, complain))
     return error_mark_node;
   if (code == FUNCTION_TYPE || is_overloaded_fn (exp))
-    return cp_build_addr_expr (exp, complain);
+    {
+      exp = mark_lvalue_use (exp);
+      if (reject_builtin && reject_gcc_builtin (exp, loc))
+       return error_mark_node;
+      return cp_build_addr_expr (exp, complain);
+    }
   if (code == ARRAY_TYPE)
     {
       tree adr;
       tree ptrtype;
 
+      exp = mark_lvalue_use (exp);
+
       if (INDIRECT_REF_P (exp))
        return build_nop (build_pointer_type (TREE_TYPE (type)),
                          TREE_OPERAND (exp, 0));
@@ -2013,6 +2017,9 @@ decay_conversion (tree exp,
       return cp_convert (ptrtype, adr, complain);
     }
 
+  /* Otherwise, it's the lvalue-to-rvalue conversion.  */
+  exp = mark_rvalue_use (exp, loc, reject_builtin);
+
   /* If a bitfield is used in a context where integral promotion
      applies, then the caller is expected to have used
      default_conversion.  That function promotes bitfields correctly
@@ -2032,6 +2039,9 @@ decay_conversion (tree exp,
   if (!CLASS_TYPE_P (type) && cv_qualified_p (type))
     exp = build_nop (cv_unqualified (type), exp);
 
+  if (!complete_type_or_maybe_complain (type, exp, complain))
+    return error_mark_node;
+
   return exp;
 }
 
diff --git a/gcc/testsuite/g++.dg/ext/asm13.C b/gcc/testsuite/g++.dg/ext/asm13.C
new file mode 100644 (file)
index 0000000..eece05e
--- /dev/null
@@ -0,0 +1,6 @@
+// PR c++/69257
+
+int fn1() {
+  struct S *x;
+  __asm ( "": :"" (*x));       // { dg-error "incomplete" }
+}
This page took 0.084371 seconds and 5 git commands to generate.