mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-01-10 18:11:19 +00:00
[Sema] Do not permit binding a reference to a compound literal
We could probably make this work if we cared enough. However, we are far outside any language rules at this point. This fixes PR21834. llvm-svn: 235818
This commit is contained in:
parent
b64b8e16db
commit
9370dc2fda
@ -3438,6 +3438,11 @@ static void TryReferenceListInitialization(Sema &S,
|
||||
Sequence.SetFailed(InitializationSequence::FK_ReferenceBindingToInitList);
|
||||
return;
|
||||
}
|
||||
// Can't reference initialize a compound literal.
|
||||
if (Entity.getKind() == InitializedEntity::EK_CompoundLiteralInit) {
|
||||
Sequence.SetFailed(InitializationSequence::FK_ReferenceBindingToInitList);
|
||||
return;
|
||||
}
|
||||
|
||||
QualType DestType = Entity.getType();
|
||||
QualType cv1T1 = DestType->getAs<ReferenceType>()->getPointeeType();
|
||||
|
@ -125,3 +125,7 @@ namespace PR20844 {
|
||||
struct B { operator A&(); } b;
|
||||
A &a{b}; // expected-error {{excess elements}} expected-note {{in initialization of temporary of type 'PR20844::A'}}
|
||||
}
|
||||
|
||||
namespace PR21834 {
|
||||
const int &a = (const int &){0}; // expected-error {{cannot bind to an initializer list}}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user