On 7/22/26 1:11 PM, Jakub Jelinek wrote:
On Wed, Jul 22, 2026 at 12:39:36PM -0400, Jason Merrill wrote:
On 7/22/26 8:54 AM, Jakub Jelinek wrote:
On Mon, Jul 20, 2026 at 05:25:19PM -0400, Jason Merrill wrote:
+ if (ANON_AGGR_TYPE_P (type))
+ {
+ /* [class.union.anon]/1: Each object of such an unnamed type shall be
+ such an unnamed object. */
+ auto_diagnostic_group d;
+ location_t aloc
+ = DECL_SOURCE_LOCATION (TYPE_MAIN_DECL (TYPE_MAIN_VARIANT (type)));
+ if (decl && VAR_P (decl) && DECL_NAME (decl) == NULL_TREE)
+ ;
This could use a comment about why this doesn't allow temporaries.
Well, there is a comment a few lines above which includes the (admittedly
bad) CWG3130 wording, so anything that can construct an object is considered
bad except for the namespace scope anonymous union declaring an unnamed
variable. Added ANON_UNION_TYPE_P test to the condition and added a comment
why is that case allowed.
Sorry for the confusion; I meant, what prevents the above code from wrongly
allowing temporaries, which are also represented as variables with null
DECL_NAME? It seems they are handled earlier somewhere.
For temporaries the function is called with !decl from what I can see.
Makes sense, please mention that in the comment. OK with that addition.
Jason