aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaDeclCXX.cpp
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2010-06-04 08:34:12 +0000
committerJohn McCall <rjmccall@apple.com>2010-06-04 08:34:12 +0000
commit4bde1e13d39e43581f7da872e4d7676ebf4a3ee7 (patch)
treeaf78dbe1daf3ec5254aac58d741be898103cf347 /lib/Sema/SemaDeclCXX.cpp
parent7b6d25b04cb86bbe6940d87dc73da8fbbebda5bd (diff)
Delay checking for mutable const fields until we're checking the field.
Allows this check to work properly for instantiated fields and removes an unnecessary GetTypeForDeclarator call. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@105463 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDeclCXX.cpp')
-rw-r--r--lib/Sema/SemaDeclCXX.cpp40
1 files changed, 10 insertions, 30 deletions
diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp
index 76a2f4f612..db7f0bb79e 100644
--- a/lib/Sema/SemaDeclCXX.cpp
+++ b/lib/Sema/SemaDeclCXX.cpp
@@ -886,10 +886,18 @@ Sema::ActOnCXXMemberDeclarator(Scope *S, AccessSpecifier AS, Declarator &D,
Expr *Init = static_cast<Expr*>(InitExpr);
SourceLocation Loc = D.getIdentifierLoc();
- bool isFunc = D.isFunctionDeclarator();
-
+ assert(isa<CXXRecordDecl>(CurContext));
assert(!DS.isFriendSpecified());
+ bool isFunc = false;
+ if (D.isFunctionDeclarator())
+ isFunc = true;
+ else if (D.getNumTypeObjects() == 0 &&
+ D.getDeclSpec().getTypeSpecType() == DeclSpec::TST_typename) {
+ QualType TDType = GetTypeFromParser(DS.getTypeRep());
+ isFunc = TDType->isFunctionType();
+ }
+
// C++ 9.2p6: A member shall not be declared to have automatic storage
// duration (auto, register) or with the extern storage-class-specifier.
// C++ 7.1.1p8: The mutable specifier can be applied only to names of class
@@ -911,22 +919,6 @@ Sema::ActOnCXXMemberDeclarator(Scope *S, AccessSpecifier AS, Declarator &D,
// FIXME: It would be nicer if the keyword was ignored only for this
// declarator. Otherwise we could get follow-up errors.
D.getMutableDeclSpec().ClearStorageClassSpecs();
- } else {
- QualType T = GetTypeForDeclarator(D, S);
- diag::kind err = static_cast<diag::kind>(0);
- if (T->isReferenceType())
- err = diag::err_mutable_reference;
- else if (T.isConstQualified())
- err = diag::err_mutable_const;
- if (err != 0) {
- if (DS.getStorageClassSpecLoc().isValid())
- Diag(DS.getStorageClassSpecLoc(), err);
- else
- Diag(DS.getThreadSpecLoc(), err);
- // FIXME: It would be nicer if the keyword was ignored only for this
- // declarator. Otherwise we could get follow-up errors.
- D.getMutableDeclSpec().ClearStorageClassSpecs();
- }
}
break;
default:
@@ -938,18 +930,6 @@ Sema::ActOnCXXMemberDeclarator(Scope *S, AccessSpecifier AS, Declarator &D,
D.getMutableDeclSpec().ClearStorageClassSpecs();
}
- if (!isFunc &&
- D.getDeclSpec().getTypeSpecType() == DeclSpec::TST_typename &&
- D.getNumTypeObjects() == 0) {
- // Check also for this case:
- //
- // typedef int f();
- // f a;
- //
- QualType TDType = GetTypeFromParser(DS.getTypeRep());
- isFunc = TDType->isFunctionType();
- }
-
bool isInstField = ((DS.getStorageClassSpec() == DeclSpec::SCS_unspecified ||
DS.getStorageClassSpec() == DeclSpec::SCS_mutable) &&
!isFunc);