]> granicus.if.org Git - clang/commitdiff
Make tentative parsing of pointer-to-member decls work, and fix other stuff pointed...
authorSebastian Redl <sebastian.redl@getdesigned.at>
Sat, 24 Jan 2009 23:29:36 +0000 (23:29 +0000)
committerSebastian Redl <sebastian.redl@getdesigned.at>
Sat, 24 Jan 2009 23:29:36 +0000 (23:29 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62944 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/ASTContext.cpp
lib/AST/Type.cpp
lib/Parse/ParseTentative.cpp
test/SemaCXX/member-pointer.cpp

index 63e4ccc24157b04e1bdbe974303cc5b79d43a168..2662860af2fef98c7379b5fa7a46e17d238ed386 100644 (file)
@@ -400,10 +400,11 @@ ASTContext::getTypeInfo(const Type *T) {
     // pointer size.
     return getTypeInfo(cast<ReferenceType>(T)->getPointeeType());
   case Type::MemberPointer: {
-    // Note that this is not only platform- but also ABI-dependent. We follow
+    // FIXME: This is not only platform- but also ABI-dependent. We follow
     // the GCC ABI, where pointers to data are one pointer large, pointers to
     // functions two pointers. But if we want to support ABI compatibility with
-    // other compilers too, we need to delegate this completely to TargetInfo.
+    // other compilers too, we need to delegate this completely to TargetInfo
+    // or some ABI abstraction layer.
     QualType Pointee = cast<MemberPointerType>(T)->getPointeeType();
     unsigned AS = Pointee.getAddressSpace();
     Width = Target.getPointerWidth(AS);
index ebaa01135555d203e115610a42c13b8f78eacbe1..7d9be2d72c705753436fbd4b7fddbe798f5443db 100644 (file)
@@ -324,6 +324,8 @@ bool Type::isVariablyModifiedType() const {
   // correctly.
   if (const PointerLikeType *PT = getAsPointerLikeType())
     return PT->getPointeeType()->isVariablyModifiedType();
+  if (const MemberPointerType *PT = getAsMemberPointerType())
+    return PT->getPointeeType()->isVariablyModifiedType();
 
   // A function can return a variably modified type
   // This one isn't completely obvious, but it follows from the
index a7c3e389319e667c3f5614bab5ad49b8d3fbd0ff..e7914cccea06b5b48af310a4584189d6e29befb1 100644 (file)
@@ -357,7 +357,7 @@ bool Parser::isCXXTypeIdInParens() {
 ///           '*' cv-qualifier-seq[opt]
 ///           '&'
 /// [C++0x]   '&&'                                                        [TODO]
-///           '::'[opt] nested-name-specifier '*' cv-qualifier-seq[opt]   [TODO]
+///           '::'[opt] nested-name-specifier '*' cv-qualifier-seq[opt]
 ///
 ///         cv-qualifier-seq:
 ///           cv-qualifier cv-qualifier-seq[opt]
@@ -387,8 +387,12 @@ Parser::TPResult Parser::TryParseDeclarator(bool mayBeAbstract,
   //   ptr-operator declarator
 
   while (1) {
-    if (Tok.is(tok::star) || Tok.is(tok::amp) || 
-        (Tok.is(tok::caret) && getLang().Blocks)) {
+    if (Tok.is(tok::coloncolon) || Tok.is(tok::identifier))
+      TryAnnotateCXXScopeToken();
+
+    if (Tok.is(tok::star) || Tok.is(tok::amp) ||
+        (Tok.is(tok::caret) && getLang().Blocks) ||
+        (Tok.is(tok::annot_cxxscope) && NextToken().is(tok::star))) {
       // ptr-operator
       ConsumeToken();
       while (Tok.is(tok::kw_const)    ||
index dcf70b2681e7a99326e366ceb28d2599d8323e3d..2568cb59d8b79495b32b59aee0ecf5b4c62665f3 100644 (file)
@@ -12,3 +12,8 @@ int B::*pbi; // expected-error {{expected a class or namespace}}
 int C::*pci; // expected-error {{'pci' does not point into a class}}
 void A::*pdv; // expected-error {{'pdv' declared as a member pointer to void}}
 int& A::*pdr; // expected-error {{'pdr' declared as a pointer to a reference}}
+
+void f() {
+  // This requires tentative parsing.
+  int (A::*pf)(int, int);
+}