Message ID | 20121211081642.GL2315@tucnak.redhat.com |
---|---|
State | New |
Headers | show |
On 12/11/2012 03:16 AM, Jakub Jelinek wrote: > + if (constraint_parsed && !allows_reg && allows_mem) > + operand = mark_rvalue_use (TREE_VALUE (t)); This should be mark_lvalue_use, since we're using its address rather than its value. OK with that change. Jason
On Tue, Dec 11, 2012 at 11:19:48AM -0500, Jason Merrill wrote: > On 12/11/2012 03:16 AM, Jakub Jelinek wrote: > >+ if (constraint_parsed && !allows_reg && allows_mem) > >+ operand = mark_rvalue_use (TREE_VALUE (t)); > > This should be mark_lvalue_use, since we're using its address rather > than its value. OK with that change. I guess it depends on how would make_lvalue_use differ from make_rvalue_use in the future. To some extent it is lvalue-ish use, but not completely, while it is taking its address, it is fine if the operand is e.g. const, which is wrong for lvalues. I'll change it, it can be adjusted when some difference between the two is actually added. Jakub
On 12/11/2012 11:33 AM, Jakub Jelinek wrote: > I guess it depends on how would make_lvalue_use differ from make_rvalue_use > in the future. To some extent it is lvalue-ish use, but not completely, > while it is taking its address, it is fine if the operand is e.g. const, > which is wrong for lvalues. In C++ lvalues can be const. Jason
--- gcc/cp/semantics.c.jj 2012-12-10 08:42:39.000000000 +0100 +++ gcc/cp/semantics.c 2012-12-10 15:24:20.666231490 +0100 @@ -1369,7 +1369,15 @@ finish_asm_stmt (int volatile_p, tree st for (i = 0, t = input_operands; t; ++i, t = TREE_CHAIN (t)) { constraint = TREE_STRING_POINTER (TREE_VALUE (TREE_PURPOSE (t))); - operand = decay_conversion (TREE_VALUE (t), tf_warning_or_error); + bool constraint_parsed + = parse_input_constraint (&constraint, i, ninputs, noutputs, 0, + oconstraints, &allows_mem, &allows_reg); + /* If the operand is going to end up in memory, don't call + decay_conversion. */ + if (constraint_parsed && !allows_reg && allows_mem) + operand = mark_rvalue_use (TREE_VALUE (t)); + else + operand = decay_conversion (TREE_VALUE (t), tf_warning_or_error); /* If the type of the operand hasn't been determined (e.g., because it involves an overloaded function), then issue @@ -1382,8 +1390,7 @@ finish_asm_stmt (int volatile_p, tree st operand = error_mark_node; } - if (parse_input_constraint (&constraint, i, ninputs, noutputs, 0, - oconstraints, &allows_mem, &allows_reg)) + if (constraint_parsed) { /* If the operand is going to end up in memory, mark it addressable. */ --- gcc/testsuite/g++.dg/ext/asm12.C.jj 2012-12-10 15:28:26.313827902 +0100 +++ gcc/testsuite/g++.dg/ext/asm12.C 2012-12-10 15:28:03.000000000 +0100 @@ -0,0 +1,14 @@ +// PR c++/55619 +// { dg-do compile } + +typedef int V __attribute__ ((vector_size (4 * sizeof (int)))); + +static const V C = { 0x201, 0, 0, 0 }; +static const int D = 0x201; + +void +f () +{ + __asm volatile ("" : : "m" (C)); + __asm volatile ("" : : "m" (D)); +}