mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-05-28 17:06:37 +00:00
50 lines
1.9 KiB
C++
50 lines
1.9 KiB
C++
//===---- SemaAccess.cpp - C++ Access Control -------------------*- C++ -*-===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This file provides Sema routines for C++ access control semantics.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "Sema.h"
|
|
using namespace clang;
|
|
|
|
/// SetMemberAccessSpecifier - Set the access specifier of a member.
|
|
/// Returns true on error (when the previous member decl access specifier
|
|
/// is different from the new member decl access specifier).
|
|
bool Sema::SetMemberAccessSpecifier(NamedDecl *MemberDecl,
|
|
NamedDecl *PrevMemberDecl,
|
|
AccessSpecifier LexicalAS) {
|
|
if (!PrevMemberDecl) {
|
|
// Use the lexical access specifier.
|
|
MemberDecl->setAccess(LexicalAS);
|
|
return false;
|
|
}
|
|
|
|
// C++ [class.access.spec]p3: When a member is redeclared its access
|
|
// specifier must be same as its initial declaration.
|
|
if (LexicalAS != AS_none && LexicalAS != PrevMemberDecl->getAccess()) {
|
|
Diag(MemberDecl->getLocation(),
|
|
diag::err_class_redeclared_with_different_access)
|
|
<< MemberDecl << LexicalAS;
|
|
Diag(PrevMemberDecl->getLocation(), diag::note_previous_access_declaration)
|
|
<< PrevMemberDecl << PrevMemberDecl->getAccess();
|
|
return true;
|
|
}
|
|
|
|
MemberDecl->setAccess(PrevMemberDecl->getAccess());
|
|
return false;
|
|
}
|
|
|
|
/// CheckBaseClassAccess - Check that a derived class can access its base class
|
|
/// and report an error if it can't. [class.access.base]
|
|
bool Sema::CheckBaseClassAccess(QualType Derived, QualType Base,
|
|
BasePaths& Paths, SourceLocation AccessLoc) {
|
|
return false;
|
|
}
|