summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDecl.cpp
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2013-04-04 21:21:25 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2013-04-04 21:21:25 +0000
commit8ac2f59017b4ba9c9aee935fa50710e2ffb8a0d4 (patch)
treef03600ca6c60926ec765f6c3982dfae4025832df /clang/lib/Sema/SemaDecl.cpp
parenta929ab58c0cf2769af0c06d01639c51a9336791e (diff)
downloadbcm5719-llvm-8ac2f59017b4ba9c9aee935fa50710e2ffb8a0d4.tar.gz
bcm5719-llvm-8ac2f59017b4ba9c9aee935fa50710e2ffb8a0d4.zip
Don't patch the storage class of static data members.
This removes a bit of patching that survived r178663. Without it we can produce better a better error message for const int a = 5; static const int a; llvm-svn: 178795
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r--clang/lib/Sema/SemaDecl.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 7a537f04e9d..adf3505633b 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -2896,9 +2896,10 @@ void Sema::MergeVarDecl(VarDecl *New, LookupResult &Previous,
if (New->isInvalidDecl())
return;
- // C99 6.2.2p4: Check if we have a static decl followed by a non-static.
+ // [dcl.stc]p8: Check if we have a non-static decl followed by a static.
if (New->getStorageClass() == SC_Static &&
- (Old->getStorageClass() == SC_None || Old->hasExternalStorage())) {
+ !New->isStaticDataMember() &&
+ isExternalLinkage(Old->getLinkage())) {
Diag(New->getLocation(), diag::err_static_non_static) << New->getDeclName();
Diag(Old->getLocation(), diag::note_previous_definition);
return New->setInvalidDecl();
@@ -2915,6 +2916,7 @@ void Sema::MergeVarDecl(VarDecl *New, LookupResult &Previous,
if (New->hasExternalStorage() && Old->hasLinkage())
/* Okay */;
else if (New->getCanonicalDecl()->getStorageClass() != SC_Static &&
+ !New->isStaticDataMember() &&
Old->getCanonicalDecl()->getStorageClass() == SC_Static) {
Diag(New->getLocation(), diag::err_non_static_static) << New->getDeclName();
Diag(Old->getLocation(), diag::note_previous_definition);
@@ -4781,8 +4783,7 @@ Sema::ActOnVariableDeclarator(Scope *S, Declarator &D, DeclContext *DC,
Diag(D.getDeclSpec().getStorageClassSpecLoc(),
diag::err_static_out_of_line)
<< FixItHint::CreateRemoval(D.getDeclSpec().getStorageClassSpecLoc());
- } else if (SC == SC_None)
- SC = SC_Static;
+ }
}
if (SC == SC_Static && CurContext->isRecord()) {
if (const CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(DC)) {
OpenPOWER on IntegriCloud