On Apr 15, 2013, at 11:01 AM, Alexander Zinenko <[email protected]> wrote:
> Finally moved this to SemaType and added more tests for pointers to function 
> appearing within other declarations.
> Could you, please, look at this?

This is the right general idea, thanks!

+  int ChunkIndex = state.getCurrentChunkIndex();
+  while (ChunkIndex != 0 &&
+         D.getTypeObject(ChunkIndex).Kind == DeclaratorChunk::Paren)
+    ChunkIndex--;

Isn't the current ChunkIndex always a DeclaratorChunk::Function?
I think you want D.getTypeObject(ChunkIndex - 1) here, although I guess
I might be off-by-one somehow.

+  bool IsCXXMethod =
+      D.getTypeObject(ChunkIndex).Kind == DeclaratorChunk::MemberPointer;
+
+  // Non-friend functions declared in member context are methods.
+  IsCXXMethod = IsCXXMethod || (D.getContext() == Declarator::MemberContext
+                                && D.isFunctionDeclarator()
+                                && !D.getDeclSpec().isFriendSpecified());

I think the right thing to do here is more like:
  bool IsCXXMethod;
  if (ChunkIndex == 0) { // CC applies to the function being declared
    assert(D.isFunctionDeclarator());
    IsCXXMethod = (D.getContext() == Declarator::MemberContext && 
!D.getDeclSpec().isFriendSpecified() && 
D.getDeclSpec().getStorageClassSpecifier() != SC_Static);
  } else {
    IsCXXMethod = D.getTypeObject(ChunkIndex - 1).Kind == 
DeclaratorChunk::MemberPointer;
  }

For out-of-line method declarations, we should just be able rely on 
redeclaration checking.

John.
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to