[cfe-commits] r111999 - in /cfe/trunk: lib/Parse/ParseExpr.cpp test/Parser/cxx-typeof.cpp

John McCall rjmccall at apple.com
Tue Aug 24 16:41:43 PDT 2010


Author: rjmccall
Date: Tue Aug 24 18:41:43 2010
New Revision: 111999

URL: http://llvm.org/viewvc/llvm-project?rev=111999&view=rev
Log:
Preserve invalidity of typeof operands in C++.


Modified:
    cfe/trunk/lib/Parse/ParseExpr.cpp
    cfe/trunk/test/Parser/cxx-typeof.cpp

Modified: cfe/trunk/lib/Parse/ParseExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExpr.cpp?rev=111999&r1=111998&r2=111999&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseExpr.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExpr.cpp Tue Aug 24 18:41:43 2010
@@ -1166,7 +1166,8 @@
       // sizeof/alignof or in C++. Therefore, the parenthesized expression is
       // the start of a unary-expression, but doesn't include any postfix 
       // pieces. Parse these now if present.
-      Operand = ParsePostfixExpressionSuffix(Operand.take());
+      if (!Operand.isInvalid())
+        Operand = ParsePostfixExpressionSuffix(Operand.get());
     }
   }
 

Modified: cfe/trunk/test/Parser/cxx-typeof.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/cxx-typeof.cpp?rev=111999&r1=111998&r2=111999&view=diff
==============================================================================
--- cfe/trunk/test/Parser/cxx-typeof.cpp (original)
+++ cfe/trunk/test/Parser/cxx-typeof.cpp Tue Aug 24 18:41:43 2010
@@ -5,3 +5,9 @@
   int x;
   typeof pi[x] y; 
 }
+
+// Part of rdar://problem/8347416;  from the gcc test suite.
+struct S {
+  int i;
+  __typeof(S::i) foo(); // expected-error {{invalid use of nonstatic data member 'i'}}
+};





More information about the cfe-commits mailing list