diff --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp --- a/clang/lib/AST/DeclBase.cpp +++ b/clang/lib/AST/DeclBase.cpp @@ -971,21 +971,19 @@ // 5. it's invalid // 6. it's a C++0x static_assert. // 7. it's a block literal declaration - if (isa(this) || - isa(this) || - isa(this) || - !getDeclContext() || - !isa(getDeclContext()) || - isInvalidDecl() || - isa(this) || - isa(this) || + // 8. it's a temporary with lifetime extended due to being default value. + if (isa(this) || isa(this) || + isa(this) || !getDeclContext() || + !isa(getDeclContext()) || isInvalidDecl() || + isa(this) || isa(this) || // FIXME: a ParmVarDecl can have ClassTemplateSpecialization // as DeclContext (?). isa(this) || // FIXME: a ClassTemplateSpecialization or CXXRecordDecl can have // AS_none as access specifier. isa(this) || - isa(this)) + isa(this) || + isa(this)) return true; assert(Access != AS_none && diff --git a/clang/test/PCH/cxx-reference.h b/clang/test/PCH/cxx-reference.h --- a/clang/test/PCH/cxx-reference.h +++ b/clang/test/PCH/cxx-reference.h @@ -11,3 +11,7 @@ LR &&rrlr = c; RR &lrrr = c; RR &&rrrr = 'c'; + +struct S { + const int &x = 1; // LifetimeExtendedTemporary inside struct +};