-
-
Notifications
You must be signed in to change notification settings - Fork 229
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
make deprecationWarnings/Errors consistent
There was different behavior in GDC and deprecationWarnings did not perform expected results with DMD and LDC.
- Loading branch information
1 parent
2ea8838
commit c045f1d
Showing
11 changed files
with
150 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
Made deprecations, warnings and errors consistent across compilers | ||
|
||
With DMD and LDC there is a special "Deprecation" compile log message class, which | ||
does not abort the build, even if `buildOptions "warningsAsErrors"` is set. With | ||
GDC this special log class doesn't exist, so previously DUB would have aborted | ||
compilation on deprecations due to the warningsAsErrors build option being set | ||
by default. | ||
|
||
DMD and LDC didn't abort the build at all if `buildOptions "deprecationWarnings"` | ||
was set, even if `"warningsAsErrors"` was (implicitly or explicitly) set. | ||
|
||
Now the behavior is consistent across all compilers: | ||
|
||
- deprecations are not treated as errors inside GDC with the default `"warningsAsErrors"` flag anymore | ||
- from this release on, the old GDC behavior can be replicated across all compilers using `buildOptions "deprecationWarnings"` | ||
- to do this with previous DUB versions, use `buildOptions "deprecationErrors"` if you haven't manually disabled the default warningsAsErrors behavior. | ||
- `"deprecationWarnings"` now implies `"deprecationErrors"` if `"warningsAsErrors"` is set (the default) | ||
|
||
Internally for GDC DUB will now emit `-Wno-error=deprecated` when build option | ||
`"warningsAsError"` is on, not aborting the build, when there is a deprecation. | ||
Note that GDC will still print "Warning" for deprecations, but not abort the | ||
build. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#!/usr/bin/env bash | ||
|
||
. $(dirname "${BASH_SOURCE[0]}")/common.sh | ||
|
||
echo "Regular run" | ||
$DUB run --force --root="$CURR_DIR/warnings" --config=executable 2>&1 >/dev/null | ||
echo "Expect bar() to be called" | ||
$DUB run --force --root="$CURR_DIR/warnings" --config=executable-d 2>&1 | grep 'called bar' -c | ||
|
||
echo "Should have no deprecation message" | ||
$DUB run --force --root="$CURR_DIR/warnings" --config=executable-d --build=no-d 2>&1 | { ! grep -F 'deprecated' -c; } | ||
echo "Deprecation should cause error" | ||
! $DUB run --force --root="$CURR_DIR/warnings" --config=executable-d --build=de 2>&1 >/dev/null | ||
echo "Deprecation should cause warning, thus an error because of default warning-as-error behavior" | ||
! $DUB run --force --root="$CURR_DIR/warnings" --config=executable-d --build=dw 2>&1 >/dev/null | ||
echo "Deprecation as error should cause error, even if warnings are allowed" | ||
! $DUB run --force --root="$CURR_DIR/warnings" --config=executable-d --build=de-allow 2>&1 >/dev/null | ||
echo "Deprecation as warning should be fine if warnings are allowed" | ||
$DUB run --force --root="$CURR_DIR/warnings" --config=executable-d --build=dw-allow 2>&1 | grep -F 'deprecated' -c | ||
echo "Allowing warnings should leave deprecations untouched" | ||
$DUB run --force --root="$CURR_DIR/warnings" --config=executable-d --build=allow 2>&1 | grep -F 'deprecated' -c | ||
|
||
echo "Expecting warning output with deprecationErrors still working as usual" | ||
$DUB run --force --root="$CURR_DIR/warnings" --config=executable-w --build=de-allow 2>&1 | grep -i 'warning' -c | ||
echo "Expecting warning output with deprecationWarnings still working as usual" | ||
$DUB run --force --root="$CURR_DIR/warnings" --config=executable-w --build=dw-allow 2>&1 | grep -i 'warning' -c | ||
echo "Expecting warning output with allowed warnings working as usual" | ||
$DUB run --force --root="$CURR_DIR/warnings" --config=executable-w --build=allow 2>&1 | grep -i 'warning' -c | ||
echo "Make sure the deprecated function didn't somehow get in" | ||
$DUB run --force --root="$CURR_DIR/warnings" --config=executable-w --build=allow 2>&1 | { ! grep 'called bar' -c; } | ||
|
||
echo "Warning should break build, deprecation should still be in" | ||
! $DUB run --force --root="$CURR_DIR/warnings" --config=executable-dw --build=no-d 2>&1 | grep -F 'deprecated' -c | ||
echo "Warning + deprecation as error should break build" | ||
! $DUB run --force --root="$CURR_DIR/warnings" --config=executable-dw --build=de 2>&1 | grep -F 'deprecated' -c | ||
echo "Warning + deprecation as warning should break build" | ||
! $DUB run --force --root="$CURR_DIR/warnings" --config=executable-dw --build=dw 2>&1 | grep -F 'deprecated' -c | ||
echo "deprecation as error with allowed warnings should break build" | ||
! $DUB run --force --root="$CURR_DIR/warnings" --config=executable-dw --build=de-allow 2>&1 >/dev/null | ||
echo "deprecation as warnings with allowed warnings should work fine" | ||
$DUB run --force --root="$CURR_DIR/warnings" --config=executable-dw --build=dw-allow 2>&1 | grep -F 'deprecated' -c | ||
echo "allowed warnings should work fine" | ||
$DUB run --force --root="$CURR_DIR/warnings" --config=executable-dw --build=allow 2>&1 | grep -F 'deprecated' -c |
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
name "warnings" | ||
|
||
configuration "executable" { | ||
targetType "executable" | ||
} | ||
|
||
configuration "executable-d" { | ||
targetType "executable" | ||
versions "Include_Deprecation" | ||
} | ||
|
||
configuration "executable-w" { | ||
targetType "executable" | ||
versions "Include_Warning" | ||
} | ||
|
||
configuration "executable-dw" { | ||
targetType "executable" | ||
versions "Include_Deprecation" "Include_Warning" | ||
} | ||
|
||
buildType "no-d" { | ||
buildRequirements "silenceDeprecations" | ||
} | ||
|
||
buildType "de" { | ||
buildOptions "deprecationErrors" | ||
} | ||
|
||
buildType "dw" { | ||
buildOptions "deprecationWarnings" | ||
} | ||
|
||
buildType "de-allow" { | ||
buildOptions "deprecationErrors" | ||
buildRequirements "allowWarnings" | ||
} | ||
|
||
buildType "dw-allow" { | ||
buildOptions "deprecationWarnings" | ||
buildRequirements "allowWarnings" | ||
} | ||
|
||
buildType "allow" { | ||
buildRequirements "allowWarnings" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import std.stdio; | ||
|
||
version(Include_Warning) | ||
{ | ||
void foo() | ||
{ | ||
return; | ||
writeln("unreachable statement"); | ||
} | ||
} | ||
|
||
version(Include_Deprecation) | ||
{ | ||
deprecated void bar() | ||
{ | ||
writeln("called bar"); | ||
} | ||
} | ||
|
||
void main() | ||
{ | ||
version(Include_Warning) | ||
foo(); | ||
|
||
version(Include_Deprecation) | ||
bar(); | ||
|
||
writeln("done"); | ||
} |