From f261ac0ea6437e5219959848602187dc92bcffa0 Mon Sep 17 00:00:00 2001
From: Roberto Raggi <roberto.raggi@nokia.com>
Date: Thu, 12 Aug 2010 17:40:13 +0200
Subject: [PATCH] Process the ptr-declarators.

---
 src/shared/cplusplus/Bind.cpp | 30 ++++++++++++++++++++++--------
 1 file changed, 22 insertions(+), 8 deletions(-)

diff --git a/src/shared/cplusplus/Bind.cpp b/src/shared/cplusplus/Bind.cpp
index ad7f5f445c4..1bf40a53a83 100644
--- a/src/shared/cplusplus/Bind.cpp
+++ b/src/shared/cplusplus/Bind.cpp
@@ -2014,32 +2014,46 @@ bool Bind::visit(EnumSpecifierAST *ast)
 // PtrOperatorAST
 bool Bind::visit(PointerToMemberAST *ast)
 {
-    // unsigned global_scope_token = ast->global_scope_token;
+    const Name *memberName = 0;
+
     for (NestedNameSpecifierListAST *it = ast->nested_name_specifier_list; it; it = it->next) {
-        /*const Name *nested_name_specifier = */ this->nestedNameSpecifier(it->value);
+        const Name *class_or_namespace_name = this->nestedNameSpecifier(it->value);
+        if (memberName || ast->global_scope_token)
+            memberName = control()->qualifiedNameId(memberName, class_or_namespace_name);
+        else
+            memberName = class_or_namespace_name;
     }
-    FullySpecifiedType type;
-    // unsigned star_token = ast->star_token;
+
+    FullySpecifiedType type(control()->pointerToMemberType(memberName, _type));
     for (SpecifierListAST *it = ast->cv_qualifier_list; it; it = it->next) {
         type = this->specifier(it->value, type);
     }
+    _type = type;
     return false;
 }
 
 bool Bind::visit(PointerAST *ast)
 {
-    // unsigned star_token = ast->star_token;
-    FullySpecifiedType type;
+    if (_type->isReferenceType())
+        translationUnit()->error(ast->firstToken(), "cannot declare pointer to a reference");
+
+    FullySpecifiedType type(control()->pointerType(_type));
     for (SpecifierListAST *it = ast->cv_qualifier_list; it; it = it->next) {
         type = this->specifier(it->value, type);
     }
+    _type = type;
     return false;
 }
 
 bool Bind::visit(ReferenceAST *ast)
 {
-    (void) ast;
-    // unsigned reference_token = ast->reference_token;
+    const bool rvalueRef = (tokenKind(ast->reference_token) == T_AMPER_AMPER);
+
+    if (_type->isReferenceType())
+        translationUnit()->error(ast->firstToken(), "cannot declare reference to a reference");
+
+    FullySpecifiedType type(control()->referenceType(_type, rvalueRef));
+    _type = type;
     return false;
 }
 
-- 
GitLab