]> granicus.if.org Git - clang/commitdiff
Preserve invalidity of typeof operands in C++.
authorJohn McCall <rjmccall@apple.com>
Tue, 24 Aug 2010 23:41:43 +0000 (23:41 +0000)
committerJohn McCall <rjmccall@apple.com>
Tue, 24 Aug 2010 23:41:43 +0000 (23:41 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111999 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Parse/ParseExpr.cpp
test/Parser/cxx-typeof.cpp

index c42fdecd7ee982647a011474e4f3278e6728619f..7020fa412e3ff8d190665880cb81fe56073fcc07 100644 (file)
@@ -1166,7 +1166,8 @@ Parser::ParseExprAfterTypeofSizeofAlignof(const Token &OpTok,
       // 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());
     }
   }
 
index 7e891013e92ce29ae9e9eb6e3a89bce86057873d..4c598e9517ed5606ff16ccbafda8950b9d3a8444 100644 (file)
@@ -5,3 +5,9 @@ static void test() {
   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'}}
+};