r179818 - Objective-C++: Enable passing of modern C++11 style

Fariborz Jahanian fjahanian at apple.com
Thu Apr 18 16:43:21 PDT 2013


Author: fjahanian
Date: Thu Apr 18 18:43:21 2013
New Revision: 179818

URL: http://llvm.org/viewvc/llvm-project?rev=179818&view=rev
Log:
Objective-C++: Enable passing of modern C++11 style 
initialized temporaries to objc++ methods. 
// rdar://12788429

Added:
    cfe/trunk/test/Parser/objcxx11-initialized-temps.mm
Modified:
    cfe/trunk/lib/Parse/ParseObjc.cpp

Modified: cfe/trunk/lib/Parse/ParseObjc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseObjc.cpp?rev=179818&r1=179817&r2=179818&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseObjc.cpp (original)
+++ cfe/trunk/lib/Parse/ParseObjc.cpp Thu Apr 18 18:43:21 2013
@@ -2501,7 +2501,14 @@ Parser::ParseObjCMessageExpressionBody(S
         return ExprError();
       }
       
-      ExprResult Res(ParseAssignmentExpression());
+      ExprResult Expr;
+      if (getLangOpts().CPlusPlus11 && Tok.is(tok::l_brace)) {
+        Diag(Tok, diag::warn_cxx98_compat_generalized_initializer_lists);
+        Expr = ParseBraceInitializer();
+      } else
+        Expr = ParseAssignmentExpression();
+      
+      ExprResult Res(Expr);
       if (Res.isInvalid()) {
         // We must manually skip to a ']', otherwise the expression skipper will
         // stop at the ']' when it skips to the ';'.  We want it to skip beyond

Added: cfe/trunk/test/Parser/objcxx11-initialized-temps.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/objcxx11-initialized-temps.mm?rev=179818&view=auto
==============================================================================
--- cfe/trunk/test/Parser/objcxx11-initialized-temps.mm (added)
+++ cfe/trunk/test/Parser/objcxx11-initialized-temps.mm Thu Apr 18 18:43:21 2013
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+// expected-no-diagnostics
+// rdar://12788429
+
+struct CGPoint {
+  double x;
+  double y;
+};
+typedef struct CGPoint CGPoint;
+
+struct CGSize {
+  double width;
+  double height;
+};
+typedef struct CGSize CGSize;
+
+struct CGRect {
+  CGPoint origin;
+  CGSize size;
+};
+typedef struct CGRect CGRect;
+
+typedef CGRect NSRect;
+
+void HappySetFrame(NSRect frame) {}
+
+__attribute__((objc_root_class))
+ at interface NSObject @end
+
+ at implementation NSObject
+- (void) sadSetFrame: (NSRect)frame {}
+
+- (void) nothing
+{
+        HappySetFrame({{0,0}, {13,14}});
+        [self sadSetFrame: {{0,0}, {13,14}}];
+}
+ at end





More information about the cfe-commits mailing list