From 499897b463f48bdce9c3ea1b20e54fac903a166f Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Sun, 23 Jan 2011 17:21:34 +0000 Subject: [PATCH] Tweak diagnostic: error: no super class declared in @interface for 'XXX' to be: error: 'X' cannot use 'super' because it is a root class The latter explains what the user actually did wrong. Fixes: llvm-svn: 124074 --- clang/include/clang/Basic/DiagnosticSemaKinds.td | 4 ++-- clang/lib/Sema/SemaExprObjC.cpp | 3 ++- clang/test/SemaObjC/undef-superclass-1.m | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 7d3c3c82c423..ce1359df22a3 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -2522,8 +2522,8 @@ def warn_inst_method_not_found : Warning< "method %objcinstance0 not found (return type defaults to 'id')">; def error_no_super_class_message : Error< "no @interface declaration found in class messaging of %0">; -def error_no_super_class : Error< - "no super class declared in @interface for %0">; +def error_root_class_cannot_use_super : Error< + "%0 cannot use 'super' because it is a root class">; def err_invalid_receiver_to_message : Error< "invalid receiver to message expression">; def err_invalid_receiver_to_message_super : Error< diff --git a/clang/lib/Sema/SemaExprObjC.cpp b/clang/lib/Sema/SemaExprObjC.cpp index ae18cc12c195..cc087a1a2d03 100644 --- a/clang/lib/Sema/SemaExprObjC.cpp +++ b/clang/lib/Sema/SemaExprObjC.cpp @@ -716,7 +716,8 @@ ExprResult Sema::ActOnSuperMessage(Scope *S, ObjCInterfaceDecl *Super = Class->getSuperClass(); if (!Super) { // The current class does not have a superclass. - Diag(SuperLoc, diag::error_no_super_class) << Class->getIdentifier(); + Diag(SuperLoc, diag::error_root_class_cannot_use_super) + << Class->getIdentifier(); return ExprError(); } diff --git a/clang/test/SemaObjC/undef-superclass-1.m b/clang/test/SemaObjC/undef-superclass-1.m index 0c2594cc226a..c941f82e435c 100644 --- a/clang/test/SemaObjC/undef-superclass-1.m +++ b/clang/test/SemaObjC/undef-superclass-1.m @@ -22,7 +22,7 @@ @implementation SUPER - (void)dealloc { - [super dealloc]; // expected-error {{no super class declared in @interface for 'SUPER'}} + [super dealloc]; // expected-error {{'SUPER' cannot use 'super' because it is a root class}} } @end