summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/compiler/scala/tools/nsc/ast/parser/Scanners.scala7
-rw-r--r--test/files/neg/t7292-deprecation.check12
-rw-r--r--test/files/neg/t7292-deprecation.flags1
-rw-r--r--test/files/neg/t7292-deprecation.scala5
-rw-r--r--test/files/neg/t7292-removal.check10
-rw-r--r--test/files/neg/t7292-removal.flags1
-rw-r--r--test/files/neg/t7292-removal.scala5
7 files changed, 41 insertions, 0 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala
index eb31f7a66e..88ff21a90d 100644
--- a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala
+++ b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala
@@ -789,6 +789,7 @@ trait Scanners extends ScannersCommon {
if (ch == '\\') {
nextChar()
if ('0' <= ch && ch <= '7') {
+ val start = charOffset - 2
val leadch: Char = ch
var oct: Int = digit2int(ch, 8)
nextChar()
@@ -800,6 +801,12 @@ trait Scanners extends ScannersCommon {
nextChar()
}
}
+ val alt = if (oct == LF) "\\n" else "\\u%04x" format oct
+ def msg(what: String) = s"Octal escape literals are $what, use $alt instead."
+ if (settings.future)
+ syntaxError(start, msg("unsupported"))
+ else
+ deprecationWarning(start, msg("deprecated"))
putChar(oct.toChar)
} else {
ch match {
diff --git a/test/files/neg/t7292-deprecation.check b/test/files/neg/t7292-deprecation.check
new file mode 100644
index 0000000000..c7e6111962
--- /dev/null
+++ b/test/files/neg/t7292-deprecation.check
@@ -0,0 +1,12 @@
+t7292-deprecation.scala:2: warning: Octal escape literals are deprecated, use /u0000 instead.
+ val chr1 = '/0'
+ ^
+t7292-deprecation.scala:3: warning: Octal escape literals are deprecated, use /u0053 instead.
+ val str1 = "abc/123456"
+ ^
+t7292-deprecation.scala:4: warning: Octal escape literals are deprecated, use /n instead.
+ val lf = '/012'
+ ^
+error: No warnings can be incurred under -Xfatal-warnings.
+three warnings found
+one error found
diff --git a/test/files/neg/t7292-deprecation.flags b/test/files/neg/t7292-deprecation.flags
new file mode 100644
index 0000000000..7de3c0f3ee
--- /dev/null
+++ b/test/files/neg/t7292-deprecation.flags
@@ -0,0 +1 @@
+-Xfatal-warnings -deprecation
diff --git a/test/files/neg/t7292-deprecation.scala b/test/files/neg/t7292-deprecation.scala
new file mode 100644
index 0000000000..d857f0e1ec
--- /dev/null
+++ b/test/files/neg/t7292-deprecation.scala
@@ -0,0 +1,5 @@
+object OctalEscapes {
+ val chr1 = '\0'
+ val str1 = "abc\123456"
+ val lf = '\012'
+}
diff --git a/test/files/neg/t7292-removal.check b/test/files/neg/t7292-removal.check
new file mode 100644
index 0000000000..fffd0a1104
--- /dev/null
+++ b/test/files/neg/t7292-removal.check
@@ -0,0 +1,10 @@
+t7292-removal.scala:2: error: Octal escape literals are unsupported, use /u0000 instead.
+ val chr1 = '/0'
+ ^
+t7292-removal.scala:3: error: Octal escape literals are unsupported, use /u0053 instead.
+ val str1 = "abc/123456"
+ ^
+t7292-removal.scala:4: error: Octal escape literals are unsupported, use /n instead.
+ val lf = '/012'
+ ^
+three errors found
diff --git a/test/files/neg/t7292-removal.flags b/test/files/neg/t7292-removal.flags
new file mode 100644
index 0000000000..29f4ede37a
--- /dev/null
+++ b/test/files/neg/t7292-removal.flags
@@ -0,0 +1 @@
+-Xfuture
diff --git a/test/files/neg/t7292-removal.scala b/test/files/neg/t7292-removal.scala
new file mode 100644
index 0000000000..d857f0e1ec
--- /dev/null
+++ b/test/files/neg/t7292-removal.scala
@@ -0,0 +1,5 @@
+object OctalEscapes {
+ val chr1 = '\0'
+ val str1 = "abc\123456"
+ val lf = '\012'
+}