aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/ObjectiveCLiterals.html12
-rw-r--r--test/CodeGenObjC/boxing.m7
2 files changed, 19 insertions, 0 deletions
diff --git a/docs/ObjectiveCLiterals.html b/docs/ObjectiveCLiterals.html
index ca7704d0a2..33f73e4a5b 100644
--- a/docs/ObjectiveCLiterals.html
+++ b/docs/ObjectiveCLiterals.html
@@ -157,6 +157,18 @@ NSNumber *red = @(Red), *green = @(Green), *blue = @(Blue); // => [NSNumber numb
then the fixed underlying type will be used to select the correct <code>NSNumber</code> creation method.
</p>
+<p>
+Boxing a value of enum type will result in a <code>NSNumber</code> pointer with a creation method according to the underlying type of the enum,
+which can be a <a href="http://clang.llvm.org/docs/LanguageExtensions.html#objc_fixed_enum">fixed underlying type</a> or a compiler-defined
+integer type capable of representing the values of all the members of the enumeration:
+</p>
+
+<pre>
+typedef enum : unsigned char { Red, Green, Blue } Color;
+Color col = Red;
+NSNumber *nsCol = @(col); // => [NSNumber numberWithUnsignedChar:]
+</pre>
+
<h3>Boxed C Strings</h3>
<p>
diff --git a/test/CodeGenObjC/boxing.m b/test/CodeGenObjC/boxing.m
index 3c24779f9a..9664298154 100644
--- a/test/CodeGenObjC/boxing.m
+++ b/test/CodeGenObjC/boxing.m
@@ -85,4 +85,11 @@ int main() {
@((NSUInteger)i);
// CHECK: load i8** [[stringWithUTF8StringSEL]]
const char *s; @(s);
+
+ typedef enum : NSInteger { Red, Green, Blue } Color;
+ // CHECK: load i8** [[WithIntegerSEL]]
+ @(Red);
+ Color col = Red;
+ // CHECK: load i8** [[WithIntegerSEL]]
+ @(col);
}