[cfe-commits] r133862 - in /cfe/trunk: lib/Sema/DeclSpec.cpp lib/Sema/SemaDeclCXX.cpp test/SemaCXX/virtuals.cpp
Richard Smith
richard-llvm at metafoo.co.uk
Fri Jun 24 19:28:38 PDT 2011
Author: rsmith
Date: Fri Jun 24 21:28:38 2011
New Revision: 133862
URL: http://llvm.org/viewvc/llvm-project?rev=133862&view=rev
Log:
Fix a couple more issues related to r133854:
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.
Modified:
cfe/trunk/lib/Sema/DeclSpec.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/test/SemaCXX/virtuals.cpp
Modified: cfe/trunk/lib/Sema/DeclSpec.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/DeclSpec.cpp?rev=133862&r1=133861&r2=133862&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/DeclSpec.cpp (original)
+++ cfe/trunk/lib/Sema/DeclSpec.cpp Fri Jun 24 21:28:38 2011
@@ -216,8 +216,22 @@
}
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:
Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=133862&r1=133861&r2=133862&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Fri Jun 24 21:28:38 2011
@@ -1079,14 +1079,7 @@
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.
Modified: cfe/trunk/test/SemaCXX/virtuals.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/virtuals.cpp?rev=133862&r1=133861&r2=133862&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/virtuals.cpp (original)
+++ cfe/trunk/test/SemaCXX/virtuals.cpp Fri Jun 24 21:28:38 2011
@@ -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 @@
namespace rdar9670557 {
typedef int func(int);
+ func *a();
struct X {
virtual func f = 0;
+ virtual func (g) = 0;
+ func *h = 0;
};
}
More information about the cfe-commits
mailing list