diff --git a/src/dmd/errors.d b/src/dmd/errors.d index 894444df3337..6e1844ef0181 100644 --- a/src/dmd/errors.d +++ b/src/dmd/errors.d @@ -21,7 +21,7 @@ import dmd.root.outbuffer; import dmd.root.rmem; import dmd.console; -/********************** +/** * Color highlighting to classify messages */ enum Classification @@ -32,8 +32,12 @@ enum Classification deprecation = Color.brightCyan, /// for deprecations } -/************************************** - * Print error message +/** + * Print an error message, increasing the global error count. + * Params: + * loc = location of error + * format = printf-style format specification + * ... = printf-style variadic arguments */ extern (C++) void error(const ref Loc loc, const(char)* format, ...) { @@ -43,7 +47,13 @@ extern (C++) void error(const ref Loc loc, const(char)* format, ...) va_end(ap); } -// This override allows Loc() literals to be passed. +/** + * Same as above, but allows Loc() literals to be passed. + * Params: + * loc = location of error + * format = printf-style format specification + * ... = printf-style variadic arguments + */ extern (D) void error(Loc loc, const(char)* format, ...) { va_list ap; @@ -52,6 +62,15 @@ extern (D) void error(Loc loc, const(char)* format, ...) va_end(ap); } +/** + * Same as above, but takes a filename and line information arguments as separate parameters. + * Params: + * filename = source file of error + * linnum = line in the source file + * charnum = column number on the line + * format = printf-style format specification + * ... = printf-style variadic arguments + */ extern (C++) void error(const(char)* filename, uint linnum, uint charnum, const(char)* format, ...) { Loc loc; @@ -64,6 +83,14 @@ extern (C++) void error(const(char)* filename, uint linnum, uint charnum, const( va_end(ap); } +/** + * Print additional details about an error message. + * Doesn't increase the error count or print an additional error prefix. + * Params: + * loc = location of error + * format = printf-style format specification + * ... = printf-style variadic arguments + */ extern (C++) void errorSupplemental(const ref Loc loc, const(char)* format, ...) { va_list ap; @@ -72,6 +99,13 @@ extern (C++) void errorSupplemental(const ref Loc loc, const(char)* format, ...) va_end(ap); } +/** + * Print a warning message, increasing the global warning count. + * Params: + * loc = location of warning + * format = printf-style format specification + * ... = printf-style variadic arguments + */ extern (C++) void warning(const ref Loc loc, const(char)* format, ...) { va_list ap; @@ -80,6 +114,14 @@ extern (C++) void warning(const ref Loc loc, const(char)* format, ...) va_end(ap); } +/** + * Print additional details about a warning message. + * Doesn't increase the warning count or print an additional warning prefix. + * Params: + * loc = location of warning + * format = printf-style format specification + * ... = printf-style variadic arguments + */ extern (C++) void warningSupplemental(const ref Loc loc, const(char)* format, ...) { va_list ap; @@ -88,6 +130,14 @@ extern (C++) void warningSupplemental(const ref Loc loc, const(char)* format, .. va_end(ap); } +/** + * Print a deprecation message, may increase the global warning or error count + * depending on whether deprecations are ignored. + * Params: + * loc = location of deprecation + * format = printf-style format specification + * ... = printf-style variadic arguments + */ extern (C++) void deprecation(const ref Loc loc, const(char)* format, ...) { va_list ap; @@ -96,6 +146,14 @@ extern (C++) void deprecation(const ref Loc loc, const(char)* format, ...) va_end(ap); } +/** + * Print additional details about a deprecation message. + * Doesn't increase the error count, or print an additional deprecation prefix. + * Params: + * loc = location of deprecation + * format = printf-style format specification + * ... = printf-style variadic arguments + */ extern (C++) void deprecationSupplemental(const ref Loc loc, const(char)* format, ...) { va_list ap; @@ -104,17 +162,17 @@ extern (C++) void deprecationSupplemental(const ref Loc loc, const(char)* format va_end(ap); } -/****************************** +/** * Just print to stderr, doesn't care about gagging. * (format,ap) text within backticks gets syntax highlighted. * Params: - * loc = location of error + * loc = location of error * headerColor = color to set `header` output to - * header = title of error message - * format = printf-style format specification - * ap = printf-style variadic arguments - * p1 = additional message prefix - * p2 = additional message prefix + * header = title of error message + * format = printf-style format specification + * ap = printf-style variadic arguments + * p1 = additional message prefix + * p2 = additional message prefix */ private void verrorPrint(const ref Loc loc, Color headerColor, const(char)* header, const(char)* format, va_list ap, const(char)* p1 = null, const(char)* p2 = null) @@ -151,7 +209,16 @@ private void verrorPrint(const ref Loc loc, Color headerColor, const(char)* head fflush(stderr); // ensure it gets written out in case of compiler aborts } -// header is "Error: " by default (see errors.h) +/** + * Same as $(D error), but takes a va_list parameter, and optionally additional message prefixes. + * Params: + * loc = location of error + * format = printf-style format specification + * ap = printf-style variadic arguments + * p1 = additional message prefix + * p2 = additional message prefix + * header = title of error message + */ extern (C++) void verror(const ref Loc loc, const(char)* format, va_list ap, const(char)* p1 = null, const(char)* p2 = null, const(char)* header = "Error: ") { global.errors++; @@ -172,7 +239,13 @@ extern (C++) void verror(const ref Loc loc, const(char)* format, va_list ap, con } } -// Doesn't increase error count, doesn't print "Error:". +/** + * Same as $(D errorSupplemental), but takes a va_list parameter. + * Params: + * loc = location of error + * format = printf-style format specification + * ap = printf-style variadic arguments + */ extern (C++) void verrorSupplemental(const ref Loc loc, const(char)* format, va_list ap) { Color color; @@ -187,6 +260,13 @@ extern (C++) void verrorSupplemental(const ref Loc loc, const(char)* format, va_ verrorPrint(loc, color, " ", format, ap); } +/** + * Same as $(D warning), but takes a va_list parameter. + * Params: + * loc = location of warning + * format = printf-style format specification + * ap = printf-style variadic arguments + */ extern (C++) void vwarning(const ref Loc loc, const(char)* format, va_list ap) { if (global.params.warnings && !global.gag) @@ -198,12 +278,28 @@ extern (C++) void vwarning(const ref Loc loc, const(char)* format, va_list ap) } } +/** + * Same as $(D warningSupplemental), but takes a va_list parameter. + * Params: + * loc = location of warning + * format = printf-style format specification + * ap = printf-style variadic arguments + */ extern (C++) void vwarningSupplemental(const ref Loc loc, const(char)* format, va_list ap) { if (global.params.warnings && !global.gag) verrorPrint(loc, Classification.warning, " ", format, ap); } +/** + * Same as $(D deprecation), but takes a va_list parameter, and optionally additional message prefixes. + * Params: + * loc = location of deprecation + * format = printf-style format specification + * ap = printf-style variadic arguments + * p1 = additional message prefix + * p2 = additional message prefix + */ extern (C++) void vdeprecation(const ref Loc loc, const(char)* format, va_list ap, const(char)* p1 = null, const(char)* p2 = null) { static __gshared const(char)* header = "Deprecation: "; @@ -213,6 +309,13 @@ extern (C++) void vdeprecation(const ref Loc loc, const(char)* format, va_list a verrorPrint(loc, Classification.deprecation, header, format, ap, p1, p2); } +/** + * Same as $(D deprecationSupplemental), but takes a va_list parameter. + * Params: + * loc = location of deprecation + * format = printf-style format specification + * ap = printf-style variadic arguments + */ extern (C++) void vdeprecationSupplemental(const ref Loc loc, const(char)* format, va_list ap) { if (global.params.useDeprecated == 0) @@ -221,7 +324,7 @@ extern (C++) void vdeprecationSupplemental(const ref Loc loc, const(char)* forma verrorPrint(loc, Classification.deprecation, " ", format, ap); } -/*************************************** +/** * Call this after printing out fatal error messages to clean up and exit * the compiler. */ @@ -234,7 +337,7 @@ extern (C++) void fatal() exit(EXIT_FAILURE); } -/************************************** +/** * Try to stop forgetting to remove the breakpoints from * release builds. */ @@ -243,7 +346,7 @@ extern (C++) void halt() assert(0); } -/********************************************** +/** * Scan characters in `buf`. Assume text enclosed by `...` * is D source code, and color syntax highlight it. * Modify contents of `buf` with highlighted result. @@ -289,9 +392,9 @@ private void colorSyntaxHighlight(OutBuffer* buf) } -/**************************** +/** * Embed these highlighting commands in the text stream. - * HIGHLIGHT.Escape indicats a Color follows. + * HIGHLIGHT.Escape indicates a Color follows. */ enum HIGHLIGHT : ubyte { @@ -304,7 +407,7 @@ enum HIGHLIGHT : ubyte Other = Color.cyan, // other tokens } -/************************************************** +/** * Highlight code for CODE section. * Rewrite the contents of `buf` with embedded highlights. * Analogous to doc.highlightCode2() @@ -380,8 +483,8 @@ private void colorHighlightCode(OutBuffer* buf) --nested; } -/************************************* - * Write the buffer contents with embedded highights to stderr. +/** + * Write the buffer contents with embedded highlights to stderr. * Params: * buf = highlighted text */