next up previous
Next: Type Analysis Up: Name Analysis Previous: Identifier occurrences


Checking for definition errors

According to Section 6.1.2.1 of the standard, an identifier can be used only within its scope. If an applied occurrence of an identifier lies outside of any scope of a defining occurrence of that identifier, the name analysis module will not be able to bind it. The module provide roles that can be inherited by symbols representing applied occurrences of identifiers in order to report such errors:

Checking for definition errors[8]:

SYMBOL LabelUse    INHERITS       ChkIdUse     END;
SYMBOL TagUse      INHERITS       ChkIdUse     END;
SYMBOL IdUse       INHERITS       ChkIdUse     END;
SYMBOL MemberIdUse INHERITS MemberChkQualIdUse END;
This macro is defined in definitions 8 and 10.
This macro is invoked in definition 1.

Section 6.1.2.1 of the standard says that label names must be unique within a function. Section 6.5 of the standard says that if an identifier has no linkage, there shall be no more than one declaration of the identifier (in a declarator or type specifier) with the same scope and in the same name space (the standard makes an exception for tags in Section 6.5.2.3 to allow for forward declarations).

Instantiate modules[9]:

$/Prop/Unique.gnrc :inst
This macro is defined in definitions 3 and 9.
This macro is invoked in definition 2.

Checking for definition errors[10]:

SYMBOL MultDefChk INHERITS Unique COMPUTE
  IF(NOT(THIS.Unique),
    message(
      ERROR,
      CatStrInd("identifier is multiply defined: ",THIS.Sym),
      0,
      COORDREF));
END;

SYMBOL LabelDef             INHERITS MultDefChk         END;
SYMBOL TagDef               INHERITS MultDefChk         END;
SYMBOL MemberIdDef          INHERITS MultDefChk         END;
SYMBOL enumeration_constant INHERITS MultDefChk         END;
SYMBOL TypeIdDef            INHERITS MultDefChk         END;
This macro is defined in definitions 8 and 10.
This macro is invoked in definition 1.


next up previous
Next: Type Analysis Up: Name Analysis Previous: Identifier occurrences
2008-08-30