-
-
Notifications
You must be signed in to change notification settings - Fork 265
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make size_t/ptrdiff_t match pointer size on 8/16 bit architectures
- Loading branch information
Showing
3 changed files
with
66 additions
and
0 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
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,26 @@ | ||
// A minimal test wrt. size_t on a 16-bit architecture. | ||
|
||
// REQUIRES: target_AVR | ||
// RUN: %ldc -mtriple=avr -betterC -output-ll -of=%t.ll %s && FileCheck %s < %t.ll | ||
// RUN: %ldc -mtriple=avr -betterC -c %s | ||
|
||
static assert(size_t.sizeof == 2); | ||
static assert(ptrdiff_t.sizeof == 2); | ||
|
||
int testBoundsCheck(int[] arr) | ||
{ | ||
return arr[1]; | ||
} | ||
|
||
// __LINE__ expressions are of type int | ||
void takeIntLine(int line = __LINE__) {} | ||
// special case for 8/16 bit targets: __LINE__ magically cast to size_t | ||
void takeSizeTLine(size_t line = __LINE__) {} | ||
|
||
void testDefaultLineArgs() | ||
{ | ||
// CHECK: call {{.*}}takeIntLine{{.*}}(i32 [[@LINE+1]]) | ||
takeIntLine(); | ||
// CHECK: call {{.*}}takeSizeTLine{{.*}}(i16 zeroext [[@LINE+1]]) | ||
takeSizeTLine(); | ||
} |