+static void AddNotifications (const Collection* LineInfos)
+/* Output additional notifications for an error or warning */
+{
+ unsigned I;
+ unsigned Skipped;
+
+ /* The basic line info is always in slot zero. It has been used to
+ * output the actual error or warning. The following slots may contain
+ * more information. Check them and print additional notifications if
+ * they're present, but limit the number to a reasonable value.
+ */
+ unsigned MaxCount = CollCount (LineInfos);
+ if (MaxCount > 6) {
+ MaxCount = 6;
+ }
+ Skipped = CollCount (LineInfos) - MaxCount;
+ for (I = 1; I < MaxCount; ++I) {
+ /* Get next line info */
+ const LineInfo* LI = CollConstAt (LineInfos, I);
+ /* Check the type and output an appropriate note */
+ unsigned Type = GetLineInfoType (LI);
+ if (Type == LI_TYPE_EXT) {
+ PrintMsg (GetSourcePos (LI), "Note",
+ "Assembler code generated from this line");
+ } else if (Type == LI_TYPE_MACRO) {
+ PrintMsg (GetSourcePos (LI), "Note",
+ "Macro was defined here");
+ }
+ }
+
+ /* Add a note if we have more stuff that we won't output */
+ if (Skipped > 0) {
+ const LineInfo* LI = CollConstAt (LineInfos, 0);
+ PrintMsg (GetSourcePos (LI), "Note",
+ "Dropping %u additional line infos", Skipped);
+ }
+}
+
+
+
+/*****************************************************************************/
+/* Warnings */
+/*****************************************************************************/
+
+
+
+static void WarningMsg (const Collection* LineInfos, const char* Format, va_list ap)
+/* Print warning message. */
+{
+ /* The first entry in the collection is that of the actual source pos */
+ const LineInfo* LI = CollConstAt (LineInfos, 0);
+
+ /* Output a warning for this position */
+ VPrintMsg (GetSourcePos (LI), "Warning", Format, ap);
+
+ /* Add additional notifications if necessary */
+ AddNotifications (LineInfos);
+
+ /* Count warnings */
+ ++WarningCount;
+}
+
+
+
+void Warning (unsigned Level, const char* Format, ...)
+/* Print warning message. */
+{
+ if (Level <= WarnLevel) {
+
+ va_list ap;
+ Collection LineInfos = STATIC_COLLECTION_INITIALIZER;
+
+ /* Get line infos for the current position */
+ GetFullLineInfo (&LineInfos);
+
+ /* Output the message */
+ va_start (ap, Format);
+ WarningMsg (&LineInfos, Format, ap);
+ va_end (ap);
+
+ /* Free the line info list */
+ ReleaseFullLineInfo (&LineInfos);
+ DoneCollection (&LineInfos);
+ }
+}
+
+
+