I'm trying to understand what some example in the Standard mean.
N2346::6.7.2.3/p12(emp. mine):
EXAMPLE 2 To illustrate the use of prior declaration of a tag to specify a pair of mutually referential structures, the declarations
struct s1 { struct s2 *s2p; /* ... */ }; // D1 struct s2 { struct s1 *s1p; /* ... */ }; // D2specify a pair of structures that contain pointers to each other. Note, however, that if
s2were already declared as a tag in an enclosing scope, the declarationD1would refer to it, not to the tags2declared inD2. To eliminate this context sensitivity, the declarationstruct s2;can be inserted ahead of
D1. This declares a new tags2in the inner scope; the declarationD2then completes the specification of the new type.
I don't really understand what the emphasized part means.
If a tag s2 would be declared in the enclosing scope e.g. as follows:
struct s2; //previous visible declaration
struct s1 { struct s2 *s2p; /* ... */ }; // D1
struct s2 { struct s1 *s1p; /* ... */ }; // D2
Then both of the declaration and the definition would specify the same type.
N2346::6.7.2.3/p8:
If a type specifier of the form
struct-or-union identifieror
enum identifieroccurs other than as part of one of the above forms, and a declaration of the identifier as a tag is visible, then it specifies the same type as that other declaration, and does not redeclare the tag.
And the type is the struct s2 { struct s1 *s1p; /* ... */ }; defined at D2.
So what does the Standard by inserting the declaration ahead of D1 to eliminate context sensitivity. I didn't see any context sensetivity here.