forked from OSchip/llvm-project
[Sema] Don't crash when a field w/ a mem-initializer clashes with a record name
It is possible for a field and a class to have the same name. In such cases, performing lookup for the field might return a result set with more than one entry. An overzealous assertion fired, causing us to crash instead of using the non-class lookup result. This fixes PR28060. llvm-svn: 272247
This commit is contained in:
parent
2769bb5753
commit
76a256260e
|
@ -2637,8 +2637,7 @@ Sema::InstantiateClassMembers(SourceLocation PointOfInstantiation,
|
||||||
Instantiation->getTemplateInstantiationPattern();
|
Instantiation->getTemplateInstantiationPattern();
|
||||||
DeclContext::lookup_result Lookup =
|
DeclContext::lookup_result Lookup =
|
||||||
ClassPattern->lookup(Field->getDeclName());
|
ClassPattern->lookup(Field->getDeclName());
|
||||||
assert(Lookup.size() == 1);
|
FieldDecl *Pattern = cast<FieldDecl>(Lookup.front());
|
||||||
FieldDecl *Pattern = cast<FieldDecl>(Lookup[0]);
|
|
||||||
InstantiateInClassInitializer(PointOfInstantiation, Field, Pattern,
|
InstantiateInClassInitializer(PointOfInstantiation, Field, Pattern,
|
||||||
TemplateArgs);
|
TemplateArgs);
|
||||||
}
|
}
|
||||||
|
|
|
@ -192,3 +192,13 @@ struct S {
|
||||||
int x[3] = {[N] = 3};
|
int x[3] = {[N] = 3};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace PR28060 {
|
||||||
|
template <class T>
|
||||||
|
void foo(T v) {
|
||||||
|
struct s {
|
||||||
|
T *s = 0;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
template void foo(int);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue