Skip to content

Commit cd87823

Browse files
committed
Warn when combining settings for the old optimizer with -YGenBCode
Remove some unnecessary flags files - neg/t4425.flags - run/blame_eye_triple_eee-double.flags - run/blame_eye_triple_eee-float.flags Force tests that use -optimize to GenASM - neg/sealed-final-neg.flags - pos/inline-access-levels.flags - pos/inliner2.flags - pos/sealed-final.flags - pos/t3420.flags - pos/t8410.flags - run/constant-optimization.flags - run/dead-code-elimination.flags - run/elidable-opt.flags - run/finalvar.flags - run/icode-reader-dead-code.scala - run/optimizer-array-load.flags - run/synchronized.flags - run/t3509.flags - run/t3569.flags - run/t4285.flags - run/t4935.flags - run/t5789.scala - run/t6188.flags - run/t7459b-optimize.flags - run/t7582.flags - run/t7582b.flags - run/t8601.flags - run/t8601b.flags - run/t8601c.flags - run/t8601d.flags - run/t8601e.flags - run/t9003.flags Move some tests to the new optimizer - run/classfile-format-51.scala - run/classfile-format-52.scala - run/run-bug4840.flags - run/t2106.flags - run/t6102.flags
1 parent c07442d commit cd87823

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+64
-83
lines changed

src/compiler/scala/tools/nsc/Global.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1373,7 +1373,7 @@ class Global(var currentSettings: Settings, var reporter: Reporter)
13731373
unitbuf += unit
13741374
compiledFiles += unit.source.file.path
13751375
}
1376-
private def checkDeprecatedSettings(unit: CompilationUnit) {
1376+
private def warnDeprecatedAndConflictingSettings(unit: CompilationUnit) {
13771377
// issue warnings for any usage of deprecated settings
13781378
settings.userSetSettings filter (_.isDeprecated) foreach { s =>
13791379
currentRun.reporting.deprecationWarning(NoPosition, s.name + " is deprecated: " + s.deprecationMessage.get)
@@ -1383,6 +1383,7 @@ class Global(var currentSettings: Settings, var reporter: Reporter)
13831383
currentRun.reporting.deprecationWarning(NoPosition, settings.target.name + ":" + settings.target.value + " is deprecated and has no effect, setting to " + supportedTarget)
13841384
settings.target.value = supportedTarget
13851385
}
1386+
settings.conflictWarning.foreach(reporter.warning(NoPosition, _))
13861387
}
13871388

13881389
/* An iterator returning all the units being compiled in this run */
@@ -1473,7 +1474,7 @@ class Global(var currentSettings: Settings, var reporter: Reporter)
14731474
def compileSources(sources: List[SourceFile]) = if (!reporter.hasErrors) {
14741475

14751476
def checkDeprecations() = {
1476-
checkDeprecatedSettings(newCompilationUnit(""))
1477+
warnDeprecatedAndConflictingSettings(newCompilationUnit(""))
14771478
reporting.summarizeErrors()
14781479
}
14791480

@@ -1495,7 +1496,7 @@ class Global(var currentSettings: Settings, var reporter: Reporter)
14951496
val startTime = currentTime
14961497

14971498
reporter.reset()
1498-
checkDeprecatedSettings(unitbuf.head)
1499+
warnDeprecatedAndConflictingSettings(unitbuf.head)
14991500
globalPhase = fromPhase
15001501

15011502
while (globalPhase.hasNext && !reporter.hasErrors) {

src/compiler/scala/tools/nsc/settings/ScalaSettings.scala

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,23 @@ trait ScalaSettings extends AbsScalaSettings
388388
val Normal = "normal"
389389
val Discard = "discard"
390390
}
391+
392+
def conflictWarning: Option[String] = {
393+
def oldOptimiseFlagsInGenBCode: Option[String] = {
394+
val optFlags: List[Setting] = if (optimise.value) List(optimise) else optimiseSettings.filter(_.value)
395+
if (isBCodeActive && optFlags.nonEmpty) {
396+
val msg = s"""Compiler settings for the 2.11 optimizer (${optFlags.map(_.name).mkString(", ")}) are incompatible with -Ybackend:GenBCode (which is the default in 2.12).
397+
|The optimizer settings are ignored. See -Yopt:help for enabling the new optimizer in 2.12.""".stripMargin
398+
Some(msg)
399+
} else
400+
None
401+
}
402+
403+
List(oldOptimiseFlagsInGenBCode /*, moreToCome */).flatten match {
404+
case Nil => None
405+
case warnings => Some("Conflicting compiler settings were detected. Some settings will be ignored.\n" + warnings.mkString("\n"))
406+
}
407+
}
391408
}
392409

393410
object ClassPathRepresentationType {
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
warning: Conflicting compiler settings were detected. Some settings will be ignored.
2+
Compiler settings for the 2.11 optimizer (-optimise) are incompatible with -Ybackend:GenBCode (which is the default in 2.12).
3+
The optimizer settings are ignored. See -Yopt:help for enabling the new optimizer in 2.12.
4+
error: No warnings can be incurred under -Xfatal-warnings.
5+
one warning found
6+
one error found
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
-optimise -Ybackend:GenBCode -Xfatal-warnings
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
class C
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
-Xfatal-warnings -Yinline-warnings -optimise
1+
-Xfatal-warnings -Ybackend:GenASM -Yinline-warnings -optimise

test/files/neg/t4425.flags

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
-optimise -Xfatal-warnings -Yinline-warnings
1+
-optimise -Ybackend:GenASM -Xfatal-warnings -Yinline-warnings

test/files/pos/inliner2.flags

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
-optimise -Xfatal-warnings
1+
-optimise -Ybackend:GenASM -Xfatal-warnings

test/files/pos/sealed-final.flags

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
-Xfatal-warnings -Yinline-warnings -optimise
1+
-Xfatal-warnings -Yinline-warnings -Ybackend:GenASM -optimise

0 commit comments

Comments
 (0)