summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAkira Hatanaka <ahatanaka@apple.com>2015-12-16 06:25:38 +0000
committerAkira Hatanaka <ahatanaka@apple.com>2015-12-16 06:25:38 +0000
commit8ebd580cf59d74a2da1d93f3893a906023701183 (patch)
tree79e93a3ddd10d3d67a3f1a427e6f9585c55aa5b7
parentc82f8961888013a0132c4ace305041742a9022f8 (diff)
downloadbcm5719-llvm-8ebd580cf59d74a2da1d93f3893a906023701183.tar.gz
bcm5719-llvm-8ebd580cf59d74a2da1d93f3893a906023701183.zip
[Objective-c] Fix a crash that occurs when ObjCTypeParamList::back() is
called on an empty list. This commit makes Parser::parseObjCTypeParamListOrProtocolRefs return nullptr if it sees an invalid type parameter (e.g., __kindof) in the type parameter list. rdar://problem/23068920 Differential Revision: http://reviews.llvm.org/D15463 llvm-svn: 255754
-rw-r--r--clang/lib/Parse/ParseObjc.cpp2
-rw-r--r--clang/test/SemaObjC/kindof.m16
2 files changed, 17 insertions, 1 deletions
diff --git a/clang/lib/Parse/ParseObjc.cpp b/clang/lib/Parse/ParseObjc.cpp
index 63c01932c1a..8a028b50376 100644
--- a/clang/lib/Parse/ParseObjc.cpp
+++ b/clang/lib/Parse/ParseObjc.cpp
@@ -603,7 +603,7 @@ ObjCTypeParamList *Parser::parseObjCTypeParamListOrProtocolRefs(
// whether there are any protocol references.
lAngleLoc = SourceLocation();
rAngleLoc = SourceLocation();
- return list;
+ return invalid ? nullptr : list;
}
/// Parse an objc-type-parameter-list.
diff --git a/clang/test/SemaObjC/kindof.m b/clang/test/SemaObjC/kindof.m
index b19e4237207..f205e68ea12 100644
--- a/clang/test/SemaObjC/kindof.m
+++ b/clang/test/SemaObjC/kindof.m
@@ -302,3 +302,19 @@ void testNullability() {
void processCopyable(__typeof(getSomeCopyable()) string);
processCopyable(0); // expected-warning{{null passed to a callee that requires a non-null argument}}
}
+
+// Check that clang doesn't crash when a type parameter is illegal.
+@interface Array1<T> : NSObject
+@end
+
+@interface I1 : NSObject
+@end
+
+@interface Array1<__kindof I1*>(extensions1) // expected-error{{expected type parameter name}}
+@end
+
+@interface Array2<T1, T2, T3> : NSObject
+@end
+
+@interface Array2<T, T, __kindof I1*>(extensions2) // expected-error{{expected type parameter name}} expected-error{{redeclaration of type parameter 'T'}}
+@end
OpenPOWER on IntegriCloud