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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@272247
91177308-0d34-0410-b5e6-
96231b3b80d8
Instantiation->getTemplateInstantiationPattern();
DeclContext::lookup_result Lookup =
ClassPattern->lookup(Field->getDeclName());
- assert(Lookup.size() == 1);
- FieldDecl *Pattern = cast<FieldDecl>(Lookup[0]);
+ FieldDecl *Pattern = cast<FieldDecl>(Lookup.front());
InstantiateInClassInitializer(PointOfInstantiation, Field, Pattern,
TemplateArgs);
}
int x[3] = {[N] = 3};
};
}
+
+namespace PR28060 {
+template <class T>
+void foo(T v) {
+ struct s {
+ T *s = 0;
+ };
+}
+template void foo(int);
+}