diff options
author | Adam Czachorowski <adamcz@google.com> | 2021-01-15 18:37:25 +0100 |
---|---|---|
committer | Adam Czachorowski <adamcz@google.com> | 2021-01-18 19:19:57 +0100 |
commit | 196cc96f9a643d1cb828f48ef15ec30d0de24df7 (patch) | |
tree | 54b4566d4a8586687d1f352e46c1b96679d4f525 /clang/lib/AST/DeclBase.cpp | |
parent | 23b0ab2acb424e3e74722c0183e5c5ac84e6ea4c (diff) | |
download | llvm-196cc96f9a643d1cb828f48ef15ec30d0de24df7.zip llvm-196cc96f9a643d1cb828f48ef15ec30d0de24df7.tar.gz llvm-196cc96f9a643d1cb828f48ef15ec30d0de24df7.tar.bz2 |
[clang] Allow LifetimeExtendedTemporary to have no access specifier
The check only runs in debug mode during serialization, but
assert()-fail on:
struct S { const int& x = 7; };
in C++ mode.
Differential Revision: https://reviews.llvm.org/D94804
Diffstat (limited to 'clang/lib/AST/DeclBase.cpp')
-rw-r--r-- | clang/lib/AST/DeclBase.cpp | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp index 0656efa..dc59f3d 100644 --- a/clang/lib/AST/DeclBase.cpp +++ b/clang/lib/AST/DeclBase.cpp @@ -971,21 +971,19 @@ bool Decl::AccessDeclContextSanity() const { // 5. it's invalid // 6. it's a C++0x static_assert. // 7. it's a block literal declaration - if (isa<TranslationUnitDecl>(this) || - isa<TemplateTypeParmDecl>(this) || - isa<NonTypeTemplateParmDecl>(this) || - !getDeclContext() || - !isa<CXXRecordDecl>(getDeclContext()) || - isInvalidDecl() || - isa<StaticAssertDecl>(this) || - isa<BlockDecl>(this) || + // 8. it's a temporary with lifetime extended due to being default value. + if (isa<TranslationUnitDecl>(this) || isa<TemplateTypeParmDecl>(this) || + isa<NonTypeTemplateParmDecl>(this) || !getDeclContext() || + !isa<CXXRecordDecl>(getDeclContext()) || isInvalidDecl() || + isa<StaticAssertDecl>(this) || isa<BlockDecl>(this) || // FIXME: a ParmVarDecl can have ClassTemplateSpecialization // as DeclContext (?). isa<ParmVarDecl>(this) || // FIXME: a ClassTemplateSpecialization or CXXRecordDecl can have // AS_none as access specifier. isa<CXXRecordDecl>(this) || - isa<ClassScopeFunctionSpecializationDecl>(this)) + isa<ClassScopeFunctionSpecializationDecl>(this) || + isa<LifetimeExtendedTemporaryDecl>(this)) return true; assert(Access != AS_none && |