[cfe-commits] r44617 - in /cfe/trunk: Sema/SemaExpr.cpp include/clang/Basic/DiagnosticKinds.def test/Parser/check-objc2-syntax-1.m

Fariborz Jahanian fjahanian at apple.com
Wed Dec 5 10:16:34 PST 2007


Author: fjahanian
Date: Wed Dec  5 12:16:33 2007
New Revision: 44617

URL: http://llvm.org/viewvc/llvm-project?rev=44617&view=rev
Log:
Patch to prevent crash on use of objc2 syntax.

Added:
    cfe/trunk/test/Parser/check-objc2-syntax-1.m
Modified:
    cfe/trunk/Sema/SemaExpr.cpp
    cfe/trunk/include/clang/Basic/DiagnosticKinds.def

Modified: cfe/trunk/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/SemaExpr.cpp?rev=44617&r1=44616&r2=44617&view=diff

==============================================================================
--- cfe/trunk/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/Sema/SemaExpr.cpp Wed Dec  5 12:16:33 2007
@@ -106,6 +106,8 @@
   }
   if (isa<TypedefDecl>(D))
     return Diag(Loc, diag::err_unexpected_typedef, II.getName());
+  if (isa<ObjcInterfaceDecl>(D))
+    return Diag(Loc, diag::err_unexpected_interface, II.getName());
 
   assert(0 && "Invalid decl");
   abort();

Modified: cfe/trunk/include/clang/Basic/DiagnosticKinds.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticKinds.def?rev=44617&r1=44616&r2=44617&view=diff

==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticKinds.def (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticKinds.def Wed Dec  5 12:16:33 2007
@@ -392,6 +392,8 @@
      "to match this '%0'")
 
 /// Objective-C parser diagnostics
+DIAG(err_unexpected_interface, ERROR,
+     "unexpected interface name '%0': expected expression")
 DIAG(err_objc_no_attributes_on_category, ERROR,
      "attributes may not be specified on a category")
 DIAG(err_objc_missing_end, ERROR,

Added: cfe/trunk/test/Parser/check-objc2-syntax-1.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/check-objc2-syntax-1.m?rev=44617&view=auto

==============================================================================
--- cfe/trunk/test/Parser/check-objc2-syntax-1.m (added)
+++ cfe/trunk/test/Parser/check-objc2-syntax-1.m Wed Dec  5 12:16:33 2007
@@ -0,0 +1,10 @@
+// RUN: clang -fsyntax-only -verify %s
+
+ at interface Subclass 
++ (int)magicNumber;
+ at end
+
+int main (void) {
+  return Subclass.magicNumber; // expected-error {{unexpected interface name 'Subclass': expected expression}}
+}
+





More information about the cfe-commits mailing list