This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
Christian BRUEL wrote:
it is the other way: with the nrv8.C (attached in the patch) test, only the check on the RESULT_DECL is necessary, testing the volatility of the *volatile A l;* object.
Oh! Right, top-level qualifiers on return types are discarded from the point of view of the language.
But, sadly, I'm still confused. Your example is:
A bar() { volatile A l; return l; }
Why is RESULT_DECL volatile in this case, before we call finalize_nrv? Is this is just an accident because we have only one return statement? For example:
A bar(bool b) { A a; volatile A va; if (b) return a; return va; }
Is the RESULT_DECL still volatile?
It seems like it would be simpler to fix this problem by changing check_return_expr to set named_return_value_okay_p to false if the TREE_TYPE (retval) is volatile. What do you think about that?
/* The cv-unqualified type of the returned value must be the same as the cv-unqualified return type of the function. */ && same_type_p ((TYPE_MAIN_VARIANT (TREE_TYPE (retval))), (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE(current_function_decl))))));
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |