[cfe-commits] r129521 - in /cfe/trunk: include/clang/Basic/DiagnosticParseKinds.td lib/Parse/ParseDeclCXX.cpp test/Parser/objcxx-at.mm

Douglas Gregor dgregor at apple.com
Thu Apr 14 10:21:19 PDT 2011


Author: dgregor
Date: Thu Apr 14 12:21:19 2011
New Revision: 129521

URL: http://llvm.org/viewvc/llvm-project?rev=129521&view=rev
Log:
Parse an '@' in an Objective-C++ class member specification,
diagnosing it as an error rather than looping infinitely. Also,
explicitly disallow @defs in Objective-C++. Fixes <rdar://problem/9260136>.

Added:
    cfe/trunk/test/Parser/objcxx-at.mm
Modified:
    cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
    cfe/trunk/lib/Parse/ParseDeclCXX.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td?rev=129521&r1=129520&r2=129521&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Thu Apr 14 12:21:19 2011
@@ -120,6 +120,9 @@
 def err_iboutletcollection_builtintype : Error<
   "type argument of iboutletcollection attribute cannot be a builtin type">;
 
+def err_at_defs_cxx : Error<"@defs is not supported in Objective-C++">;
+def err_at_in_class : Error<"unexpected '@' in member specification">;
+
 def err_expected_fn_body : Error<
   "expected function body after function declarator">;
 def err_expected_method_body : Error<"expected method body">;
@@ -370,8 +373,8 @@
 
 def err_missing_dependent_template_keyword : Error<
   "use 'template' keyword to treat '%0' as a dependent template name">;
-def war_missing_dependent_template_keyword : ExtWarn<
-  "use 'template' keyword to treat '%0' as a dependent template name">;
+def war_missing_dependent_template_keyword : ExtWarn<
+  "use 'template' keyword to treat '%0' as a dependent template name">;
 
 def warn_static_inline_explicit_inst_ignored : Warning<
   "ignoring '%select{static|inline}0' keyword on explicit template "

Modified: cfe/trunk/lib/Parse/ParseDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDeclCXX.cpp?rev=129521&r1=129520&r2=129521&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseDeclCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDeclCXX.cpp Thu Apr 14 12:21:19 2011
@@ -1374,6 +1374,17 @@
 void Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS,
                                        const ParsedTemplateInfo &TemplateInfo,
                                        ParsingDeclRAIIObject *TemplateDiags) {
+  if (Tok.is(tok::at)) {
+    if (getLang().ObjC1 && NextToken().isObjCAtKeyword(tok::objc_defs))
+      Diag(Tok, diag::err_at_defs_cxx);
+    else
+      Diag(Tok, diag::err_at_in_class);
+    
+    ConsumeToken();
+    SkipUntil(tok::r_brace);
+    return;
+  }
+  
   // Access declarations.
   if (!TemplateInfo.Kind &&
       (Tok.is(tok::identifier) || Tok.is(tok::coloncolon)) &&

Added: cfe/trunk/test/Parser/objcxx-at.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/objcxx-at.mm?rev=129521&view=auto
==============================================================================
--- cfe/trunk/test/Parser/objcxx-at.mm (added)
+++ cfe/trunk/test/Parser/objcxx-at.mm Thu Apr 14 12:21:19 2011
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+ at interface B {
+  int i;
+}
+ at end
+
+struct Z {
+  @defs(B); // expected-error{{@defs is not supported in Objective-C++}}
+};
+
+struct Y { // expected-note{{to match this '{'}}
+  struct X { } // expected-error{{expected ';' after struct}}
+    @interface A // expected-error{{unexpected '@' in member specification}}
+} // expected-error{{expected '}'}} expected-error{{expected ';' after struct}}





More information about the cfe-commits mailing list