]> granicus.if.org Git - clang/commitdiff
Fix a couple more issues related to r133854:
authorRichard Smith <richard-llvm@metafoo.co.uk>
Sat, 25 Jun 2011 02:28:38 +0000 (02:28 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Sat, 25 Jun 2011 02:28:38 +0000 (02:28 +0000)
When performing semantic analysis on a member declaration, fix the check for whether we are declaring a function to check for parenthesized declarators, declaration via decltype, etc.

Also fix the semantic check to not treat FuncType* as a function type.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133862 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/DeclSpec.cpp
lib/Sema/SemaDeclCXX.cpp
test/SemaCXX/virtuals.cpp

index d450a32e77df20286d9943ac14972294d1686496..c5b883e46d3f539f4112ed78e3697815871c72d7 100644 (file)
@@ -216,8 +216,22 @@ DeclaratorChunk DeclaratorChunk::getFunction(bool hasProto, bool isVariadic,
 }
 
 bool Declarator::isDeclarationOfFunction() const {
-  if (isFunctionDeclarator())
-    return true;
+  for (unsigned i = 0, i_end = DeclTypeInfo.size(); i < i_end; ++i) {
+    switch (DeclTypeInfo[i].Kind) {
+    case DeclaratorChunk::Function:
+      return true;
+    case DeclaratorChunk::Paren:
+      continue;
+    case DeclaratorChunk::Pointer:
+    case DeclaratorChunk::Reference:
+    case DeclaratorChunk::Array:
+    case DeclaratorChunk::BlockPointer:
+    case DeclaratorChunk::MemberPointer:
+      return false;
+    }
+    llvm_unreachable("Invalid type chunk");
+    return false;
+  }
   
   switch (DS.getTypeSpecType()) {
     case TST_auto:
index a7bd46a2ca751747b93fc742cf57163871f56381..07eb9fe572aa4a696bfb79e7caa5406bdaa93a68 100644 (file)
@@ -1079,14 +1079,7 @@ Sema::ActOnCXXMemberDeclarator(Scope *S, AccessSpecifier AS, Declarator &D,
   assert(!DS.isFriendSpecified());
   assert(!Init || !HasDeferredInit);
 
-  bool isFunc = false;
-  if (D.isFunctionDeclarator())
-    isFunc = true;
-  else if (D.getNumTypeObjects() == 0 &&
-           D.getDeclSpec().getTypeSpecType() == DeclSpec::TST_typename) {
-    QualType TDType = GetTypeFromParser(DS.getRepAsType());
-    isFunc = TDType->isFunctionType();
-  }
+  bool isFunc = D.isDeclarationOfFunction();
 
   // C++ 9.2p6: A member shall not be declared to have automatic storage
   // duration (auto, register) or with the extern storage-class-specifier.
index 8fe7a33a1c67898d16f204188119da4d145293b6..d8c26efcfb4292e82a19184534056fbf6c7d20ac 100644 (file)
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -verify %s
+// RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -verify -std=c++0x %s
 
 class A {
   virtual void f();
@@ -38,7 +38,10 @@ A fn(A) // expected-error{{parameter type 'A' is an abstract class}} \
 
 namespace rdar9670557 {
   typedef int func(int);
+  func *a();
   struct X {
     virtual func f = 0;
+    virtual func (g) = 0;
+    func *h = 0;
   };
 }