Rule 5.7 - Uniqueness of Tags as Identifiers

Moderators: misra-c, david ward

Post Reply
j-nafziger
Posts: 1
Joined: Thu Dec 12, 2019 1:28 pm
Company: Texas Instruments

Rule 5.7 - Uniqueness of Tags as Identifiers

Post by j-nafziger » Wed Jul 01, 2020 4:13 pm

Hi -

The amplification in Rule 5.7 says that a tag shall be unique across all name spaces and translation units.

Should this be read such that:
- A tag shall be unique across (all tags in) all name spaces and translation units.
- A tag shall be unique across (all identifiers in) all name spaces and translation units.

The distinction I am drawing being could a unique identifier of a tag be reused for other non-tag identifiers?

The examples in Rule 5.7 only show conflicts between tags and do not show conflicts between tags and other kinds of identifiers (labels, members, ordinary identifiers).

For example is this code violating Rule 5.7 (reuse of 'device' as a member and a tag)?

Code: Select all

struct clock {
	u32	 device;  /* Device is a 'member' */
} ;
struct device;  /* device is a tag */
Thanks!

misra-c
Posts: 572
Joined: Thu Jan 05, 2006 1:11 pm

Re: Rule 5.7 - Uniqueness of Tags as Identifiers

Post by misra-c » Wed Aug 05, 2020 9:31 am

The rule should be read as
"A tag shall be unique across (all identifiers in) all name spaces and translation units."
The example you give is non compliant with rule 5.7.
---
Posted by and on behalf of
the MISRA C Working Group

Post Reply

Return to “8.5 Identifers”