aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Naroff <snaroff@apple.com>2008-03-28 21:37:05 +0000
committerSteve Naroff <snaroff@apple.com>2008-03-28 21:37:05 +0000
commit95110968dcd6ba2baef2a23549cd5592f01eca59 (patch)
tree729db6ec9d5e9cdd6b8b0afa35684df96d29ffb0
parent8730e130ab77ae5739e6339e1544b4ca9ab28450 (diff)
Make sure Sema::ActOnClassMessage() correctly diagnoses "super".
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@48924 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/Basic/DiagnosticKinds.def2
-rw-r--r--lib/Sema/SemaExprObjC.cpp5
-rw-r--r--test/Sema/undef-superclass-1.m6
3 files changed, 12 insertions, 1 deletions
diff --git a/include/clang/Basic/DiagnosticKinds.def b/include/clang/Basic/DiagnosticKinds.def
index c3825624e4..a6e6529e5f 100644
--- a/include/clang/Basic/DiagnosticKinds.def
+++ b/include/clang/Basic/DiagnosticKinds.def
@@ -477,6 +477,8 @@ DIAG(error_missing_method_context, ERROR,
"missing context for method declaration")
DIAG(error_bad_receiver_type, ERROR,
"bad receiver type '%0'")
+DIAG(error_no_super_class, ERROR,
+ "no super class declared in @interface for '%0'")
//===----------------------------------------------------------------------===//
// Semantic Analysis
diff --git a/lib/Sema/SemaExprObjC.cpp b/lib/Sema/SemaExprObjC.cpp
index 4cf435c331..1a274e126e 100644
--- a/lib/Sema/SemaExprObjC.cpp
+++ b/lib/Sema/SemaExprObjC.cpp
@@ -146,7 +146,10 @@ Sema::ExprResult Sema::ActOnClassMessage(
ObjCInterfaceDecl* ClassDecl = 0;
if (!strcmp(receiverName->getName(), "super") && CurMethodDecl) {
ClassDecl = CurMethodDecl->getClassInterface()->getSuperClass();
- if (ClassDecl && CurMethodDecl->isInstance()) {
+ if (!ClassDecl)
+ return Diag(lbrac, diag::error_no_super_class,
+ CurMethodDecl->getClassInterface()->getName());
+ if (CurMethodDecl->isInstance()) {
// Synthesize a cast to the super class. This hack allows us to loosely
// represent super without creating a special expression node.
IdentifierInfo &II = Context.Idents.get("self");
diff --git a/test/Sema/undef-superclass-1.m b/test/Sema/undef-superclass-1.m
index 822b97185b..7e12463654 100644
--- a/test/Sema/undef-superclass-1.m
+++ b/test/Sema/undef-superclass-1.m
@@ -18,3 +18,9 @@
@interface INTF1 // expected-error {{duplicate interface declaration for class 'INTF1'}}
@end
+
+@implementation SUPER
+- (void)dealloc {
+ [super dealloc]; // expected-error {{no super class declared in @interface for 'SUPER'}}
+}
+@end