Skip to content

Commit

Permalink
Merge pull request swiftlang#780 from apple/revert-281-master
Browse files Browse the repository at this point in the history
Revert "Removed the ++ and -- operators"
  • Loading branch information
gribozavr committed Dec 26, 2015
2 parents 07d4558 + 9d5cbc4 commit 36a9e59
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 30 deletions.
2 changes: 1 addition & 1 deletion test/IDE/complete_stmt_controlling_expr.swift
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ func testCStyleForBodyI5(fooObject: FooStruct) {
func testCStyleForBodyI6(fooObject: FooStruct) {
var localInt = 42
var localFooObject = FooStruct(localInt)
for var i = 0; ; unknown_var += 1 {
for var i = 0; ; unknown_var++ {
#^C_STYLE_FOR_BODY_I_6^#
}
}
Expand Down
4 changes: 2 additions & 2 deletions test/Interpreter/break_continue.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func test1() {
func test2() {
print("test2")
var i : Int
for i in 0..<10 {
for i=0;i<10;i += 1 {
if i > 2 {
continue
}
Expand All @@ -25,7 +25,7 @@ func test2() {
func test3() {
print("test3")
var i : Int
for i in 0..<10 {
for i=0;i<10;i += 1 {
if i > 2 {
break
}
Expand Down
Empty file modified test/Parse/recovery.swift
100755 → 100644
Empty file.
11 changes: 5 additions & 6 deletions test/Prototypes/MutableIndexableDict.swift
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ struct FixedSizedRefArrayOfOptional<T>
init(capacity: Int)
{
buffer = Storage.Buffer(Storage.self, capacity, capacity)
for i in 0..<capacity {
for var i = 0; i < capacity; ++i {
(buffer.baseAddress + i).initialize(.None)
}

Expand Down Expand Up @@ -181,12 +181,11 @@ struct DictionaryIndex<Element> : BidirectionalIndexType {
typealias Index = DictionaryIndex<Element>

func predecessor() -> Index {
var j = self.offset - 1
while j > 0 {
var j = self.offset
while --j > 0 {
if buffer[j] != nil {
return Index(buffer: buffer, offset: j)
}
j -= 1
}
return self
}
Expand Down Expand Up @@ -276,7 +275,7 @@ struct Dictionary<Key: Hashable, Value> : CollectionType, SequenceType {
_buffer[i.offset] = Element(key: key, value: value)

if !found {
_count += 1
++_count
}
}
}
Expand Down Expand Up @@ -361,7 +360,7 @@ struct Dictionary<Key: Hashable, Value> : CollectionType, SequenceType {

// remove the element
_buffer[pos.offset] = .None
_count -= 1
--_count

// If we've put a hole in a chain of contiguous elements, some
// element after the hole may belong where the new hole is.
Expand Down
8 changes: 3 additions & 5 deletions test/SILGen/coverage_while.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,13 @@ func foo() -> Int32 {
}

// CHECK: [[@LINE+1]]:9 -> [[@LINE+1]]:18 : (0 + 2)
while (x > 0) {
if (x % 2 == 0) { x -= 1; continue }
x -= 1
while (--x > 0) {
if (x % 2 == 0) { continue }
}

// CHECK: [[@LINE+1]]:9 -> [[@LINE+1]]:18 : ((0 + 4) - 5)
while (x < 100) {
if (x == 10) { break }
x += 1
if (x++ == 10) { break }
}

// CHECK: [[@LINE+1]]:9 -> [[@LINE+1]]:18 : ((0 + 6) - 9)
Expand Down
18 changes: 9 additions & 9 deletions test/SILGen/sil_locations.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
func ifexpr() -> Int {
var x : Int = 0
if true {
x += 1;
x++;
}
return x
// CHECK-LABEL: sil hidden @_TF13sil_locations6ifexprFT_Si
Expand All @@ -18,9 +18,9 @@ func ifexpr() -> Int {
func ifelseexpr() -> Int {
var x : Int = 0
if true {
x += 1;
x++;
} else {
x -= 1;
x--;
}
return x
// CHECK-LABEL: sil hidden @_TF13sil_locations10ifelseexprFT_Si
Expand Down Expand Up @@ -64,7 +64,7 @@ func ifexpr_rval() -> Int {

// TODO: missing info on the first branch.
func forstmt_empty_cond(i: Int) -> Int {
for var i=0;; i += 1 {}
for var i=0;;++i {}
// CHECK-LABEL: sil hidden @{{.*}}forstmt_empty_cond{{.*}}
// CHECK: apply {{.*}} line:[[@LINE-2]]:13
// CHECK: br [[TRUE_BB:bb[0-9]+]]
Expand Down Expand Up @@ -116,7 +116,7 @@ func multipleReturnsImplicitAndExplicit() {
if x > 10 {
return
}
x += 1;
x++;
// CHECK-LABEL: sil hidden @_TF13sil_locations34multipleReturnsImplicitAndExplicitFT_T_
// CHECK: cond_br
// CHECK: br bb{{[0-9]+}} // {{.*}} line:[[@LINE-5]]:5:return
Expand Down Expand Up @@ -175,13 +175,13 @@ func testIf() {
}

func testFor() {
for i in 0..<10 {
for (var i:Int = 0; i<10; i++) {
var y: Int = 300
y += 1;
y++;
if true {
break
}
y -= 1;
y--;
continue
}

Expand Down Expand Up @@ -352,7 +352,7 @@ func testStringForEachStmt() {
func testForStmt() {
var i = 0
var m = 0
for i in 0..<10 {
for (i = 0; i < 10; ++i) {
m += 1
if m == 15 {
break
Expand Down
6 changes: 3 additions & 3 deletions test/Sema/immutability.swift
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func let_decls() {


let e = 42 // expected-note {{change 'let' to 'var' to make it mutable}} {{3-6=var}}
e += 1 // expected-error {{cannot pass immutable value to mutating operator: 'e' is a 'let' constant}}
++e // expected-error {{cannot pass immutable value to mutating operator: 'e' is a 'let' constant}}

// <rdar://problem/16306600> QoI: passing a 'let' value as an inout results in an unfriendly diagnostic
let f = 96 // expected-note {{change 'let' to 'var' to make it mutable}} {{3-6=var}}
Expand Down Expand Up @@ -322,8 +322,8 @@ func testSelectorStyleArguments1(x: Int, bar y: Int) {

func testSelectorStyleArguments2(x: Int,
bar y: Int) {
x += 1 // expected-error {{cannot pass immutable value to mutating operator: 'x' is a 'let' constant}}
y += 1 // expected-error {{cannot pass immutable value to mutating operator: 'y' is a 'let' constant}}
++x // expected-error {{cannot pass immutable value to mutating operator: 'x' is a 'let' constant}}
++y // expected-error {{cannot pass immutable value to mutating operator: 'y' is a 'let' constant}}
}

func invalid_inout(inout var x : Int) { // expected-error {{parameter may not have multiple 'inout', 'var', or 'let' specifiers}} {{26-30=}}
Expand Down
2 changes: 1 addition & 1 deletion test/SourceKit/DocumentStructure/Inputs/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ var (sd2: Qtys)
}

for i in 0...5 {}
for var i = 0, i2 = 1; i == 0; i += 1 {}
for var i = 0, i2 = 1; i == 0; ++i {}
while let v = o, z = o where v > z {}
repeat {} while v == 0
if let v = o, z = o where v > z {}
Expand Down
4 changes: 2 additions & 2 deletions test/SourceKit/Indexing/index.swift
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,10 @@ func test1(cp: ComputedProperty, sub: CC2) {
var x = cp.value
x = cp.readOnly
cp.value = x
cp.value += 1
++cp.value
x = sub[0]
sub[0] = x
sub[0] += 1
++sub[0]
}

struct S2 {
Expand Down
2 changes: 1 addition & 1 deletion validation-test/stdlib/OpenCLSDKOverlay.swift
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ tests.test("clSetKernelArgsListAPPLE") {
// Validate our results
//
correct = 0
for i in 0..<count
for(i = 0; i < count; i++)
{
if(results[i] == data[i] * data[i]){
correct += 1
Expand Down

0 comments on commit 36a9e59

Please sign in to comment.