Make sure Sema::ActOnClassMessage() correctly diagnoses "super".


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@48924 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/clang/Basic/DiagnosticKinds.def b/include/clang/Basic/DiagnosticKinds.def
index c382562..a6e6529 100644
--- a/include/clang/Basic/DiagnosticKinds.def
+++ b/include/clang/Basic/DiagnosticKinds.def
@@ -477,6 +477,8 @@
      "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 4cf435c..1a274e1 100644
--- a/lib/Sema/SemaExprObjC.cpp
+++ b/lib/Sema/SemaExprObjC.cpp
@@ -146,7 +146,10 @@
   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 822b971..7e12463 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