Skip to content
Snippets Groups Projects
Commit 80ed2a64 authored by Andrew Pinski's avatar Andrew Pinski
Browse files

c: [PR84900] cast of compound literal does not cause the code to become a non-lvalue

The problem here is after r0-92187-g2ec5deb5c3146c, maybe_lvalue_p would
return false for compound literals which causes non_lvalue_loc not
to wrap the expression with a NON_LVALUE_EXPR unlike before when it
return true as it returns true for all language specific tree codes.

This fixes that oversight and fixes the testcase to have the cast as
a non-lvalue.

Committed to the trunk as obvious after a bootstrap/test on x86_64-linux-gnu.

	PR c/84900

gcc/ChangeLog:

	* fold-const.cc (maybe_lvalue_p): Treat COMPOUND_LITERAL_EXPR
	as a lvalue.

gcc/testsuite/ChangeLog:

	* gcc.dg/compound-literal-cast-lvalue-1.c: New test.
parent 5ededfa5
No related branches found
No related tags found
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment