[cfe-commits] r48924 - in /cfe/trunk: include/clang/Basic/DiagnosticKinds.def lib/Sema/SemaExprObjC.cpp test/Sema/undef-superclass-1.m
Steve Naroff
snaroff at apple.com
Fri Mar 28 14:37:06 PDT 2008
Author: snaroff
Date: Fri Mar 28 16:37:05 2008
New Revision: 48924
URL: http://llvm.org/viewvc/llvm-project?rev=48924&view=rev
Log:
Make sure Sema::ActOnClassMessage() correctly diagnoses "super".
Modified:
cfe/trunk/include/clang/Basic/DiagnosticKinds.def
cfe/trunk/lib/Sema/SemaExprObjC.cpp
cfe/trunk/test/Sema/undef-superclass-1.m
Modified: cfe/trunk/include/clang/Basic/DiagnosticKinds.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticKinds.def?rev=48924&r1=48923&r2=48924&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticKinds.def (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticKinds.def Fri Mar 28 16:37:05 2008
@@ -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
Modified: cfe/trunk/lib/Sema/SemaExprObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprObjC.cpp?rev=48924&r1=48923&r2=48924&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprObjC.cpp Fri Mar 28 16:37:05 2008
@@ -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");
Modified: cfe/trunk/test/Sema/undef-superclass-1.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/undef-superclass-1.m?rev=48924&r1=48923&r2=48924&view=diff
==============================================================================
--- cfe/trunk/test/Sema/undef-superclass-1.m (original)
+++ cfe/trunk/test/Sema/undef-superclass-1.m Fri Mar 28 16:37:05 2008
@@ -18,3 +18,9 @@
@interface INTF1 // expected-error {{duplicate interface declaration for class 'INTF1'}}
@end
+
+ at implementation SUPER
+- (void)dealloc {
+ [super dealloc]; // expected-error {{no super class declared in @interface for 'SUPER'}}
+}
+ at end
More information about the cfe-commits
mailing list