Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/dmd/compiler.d
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import dmd.globals;
import dmd.id;
import dmd.identifier;
import dmd.mtype;
import dmd.lexer;
import dmd.parse;
import dmd.root.array;
import dmd.root.ctfloat;
Expand Down
1 change: 1 addition & 0 deletions src/dmd/dmodule.d
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import dmd.expressionsem;
import dmd.globals;
import dmd.id;
import dmd.identifier;
import dmd.lexer;
import dmd.parse;
import dmd.root.file;
import dmd.root.filename;
Expand Down
1 change: 1 addition & 0 deletions src/dmd/dsymbolsem.d
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import dmd.identifier;
import dmd.init;
import dmd.initsem;
import dmd.hdrgen;
import dmd.lexer;
import dmd.mtype;
import dmd.nogc;
import dmd.nspace;
Expand Down
205 changes: 0 additions & 205 deletions src/dmd/errors.d
Original file line number Diff line number Diff line change
Expand Up @@ -21,211 +21,6 @@ import dmd.root.outbuffer;
import dmd.root.rmem;
import dmd.console;

/// Interface for diagnostic reporting.
abstract class DiagnosticReporter
{
/// Returns: the number of errors that occurred during lexing or parsing.
abstract int errorCount();

/// Returns: the number of warnings that occurred during lexing or parsing.
abstract int warningCount();

/// Returns: the number of deprecations that occurred during lexing or parsing.
abstract int deprecationCount();

/**
Reports an error message.

Params:
loc = Location of error
format = format string for error
... = format string arguments
*/
final void error(const ref Loc loc, const(char)* format, ...)
{
va_list args;
va_start(args, format);
error(loc, format, args);
va_end(args);
}

/// ditto
abstract void error(const ref Loc loc, const(char)* format, va_list args);

/**
Reports additional details about an error message.

Params:
loc = Location of error
format = format string for supplemental message
... = format string arguments
*/
final void errorSupplemental(const ref Loc loc, const(char)* format, ...)
{
va_list args;
va_start(args, format);
errorSupplemental(loc, format, args);
va_end(args);
}

/// ditto
abstract void errorSupplemental(const ref Loc loc, const(char)* format, va_list);

/**
Reports a warning message.

Params:
loc = Location of warning
format = format string for warning
... = format string arguments
*/
final void warning(const ref Loc loc, const(char)* format, ...)
{
va_list args;
va_start(args, format);
warning(loc, format, args);
va_end(args);
}

/// ditto
abstract void warning(const ref Loc loc, const(char)* format, va_list args);

/**
Reports additional details about a warning message.

Params:
loc = Location of warning
format = format string for supplemental message
... = format string arguments
*/
final void warningSupplemental(const ref Loc loc, const(char)* format, ...)
{
va_list args;
va_start(args, format);
warningSupplemental(loc, format, args);
va_end(args);
}

/// ditto
abstract void warningSupplemental(const ref Loc loc, const(char)* format, va_list);

/**
Reports a deprecation message.

Params:
loc = Location of the deprecation
format = format string for the deprecation
... = format string arguments
*/
final void deprecation(const ref Loc loc, const(char)* format, ...)
{
va_list args;
va_start(args, format);
deprecation(loc, format, args);
va_end(args);
}

/// ditto
abstract void deprecation(const ref Loc loc, const(char)* format, va_list args);

/**
Reports additional details about a deprecation message.

Params:
loc = Location of deprecation
format = format string for supplemental message
... = format string arguments
*/
final void deprecationSupplemental(const ref Loc loc, const(char)* format, ...)
{
va_list args;
va_start(args, format);
deprecationSupplemental(loc, format, args);
va_end(args);
}

/// ditto
abstract void deprecationSupplemental(const ref Loc loc, const(char)* format, va_list);
}

/**
Diagnostic reporter which prints the diagnostic messages to stderr.

This is usually the default diagnostic reporter.
*/
final class StderrDiagnosticReporter : DiagnosticReporter
{
private const DiagnosticReporting useDeprecated;

private int errorCount_;
private int warningCount_;
private int deprecationCount_;

/**
Initializes this object.

Params:
useDeprecated = indicates how deprecation diagnostics should be
handled
*/
this(DiagnosticReporting useDeprecated)
{
this.useDeprecated = useDeprecated;
}

override int errorCount()
{
return errorCount_;
}

override int warningCount()
{
return warningCount_;
}

override int deprecationCount()
{
return deprecationCount_;
}

override void error(const ref Loc loc, const(char)* format, va_list args)
{
verror(loc, format, args);
errorCount_++;
}

override void errorSupplemental(const ref Loc loc, const(char)* format, va_list args)
{
verrorSupplemental(loc, format, args);
}

override void warning(const ref Loc loc, const(char)* format, va_list args)
{
vwarning(loc, format, args);
warningCount_++;
}

override void warningSupplemental(const ref Loc loc, const(char)* format, va_list args)
{
vwarningSupplemental(loc, format, args);
}

override void deprecation(const ref Loc loc, const(char)* format, va_list args)
{
vdeprecation(loc, format, args);

if (useDeprecated == DiagnosticReporting.error)
errorCount_++;
else
deprecationCount_++;
}

override void deprecationSupplemental(const ref Loc loc, const(char)* format, va_list args)
{
vdeprecationSupplemental(loc, format, args);
}
}

/**
* Color highlighting to classify messages
*/
Expand Down
1 change: 1 addition & 0 deletions src/dmd/expressionsem.d
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import dmd.identifier;
import dmd.imphint;
import dmd.inline;
import dmd.intrange;
import dmd.lexer;
import dmd.mtype;
import dmd.nspace;
import dmd.opover;
Expand Down
4 changes: 2 additions & 2 deletions src/dmd/frontend.d
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
module dmd.frontend;

import dmd.dmodule : Module;
import dmd.errors : DiagnosticReporter;
import dmd.lexer : DiagnosticReporter;

import std.range.primitives : isInputRange, ElementType;
import std.traits : isNarrowString;
Expand Down Expand Up @@ -374,7 +374,7 @@ string prettyPrint(Module m)
private DiagnosticReporter defaultDiagnosticReporter()
{
import dmd.globals : global;
import dmd.errors : StderrDiagnosticReporter;
import dmd.lexer : StderrDiagnosticReporter;

return new StderrDiagnosticReporter(global.params.useDeprecated);
}
2 changes: 1 addition & 1 deletion src/dmd/iasmgcc.d
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ import core.stdc.string;
import dmd.arraytypes;
import dmd.astcodegen;
import dmd.dscope;
import dmd.errors;
import dmd.expression;
import dmd.expressionsem;
import dmd.identifier;
import dmd.globals;
import dmd.lexer;
import dmd.parse;
import dmd.tokens;
import dmd.statement;
Expand Down
Loading