void Sema::ActOnTypeDeclSpec(ASTContext &C, SourceLocation Loc, const IdentifierInfo *IDInfo, DeclSpec &DS) { DS.SetTypeSpecType(DeclSpec::TST_struct); auto D = ResolveIdentifier(IDInfo); if(!D) { Diags.Report(Loc, diag::err_undeclared_var_use) << IDInfo; return; } auto Record = dyn_cast<RecordDecl>(D); if(!Record) { Diags.Report(Loc, diag::err_use_of_not_typename) << IDInfo; return; } DS.setRecord(Record); }
RState* RSNrValue::Shift(addr_t v, int32 token, RElem** head) { if (token == tIdent) { int32 id = v; if (ResolveIdentifier(v)) RAddElement(head, RValue(v), fSize, this); else error("Unknown identifier: %s", ST_Ident(id)); } else if (token == tInt) RAddElement(head, (REval *)v, fSize, this); else if (fHasDefault) { RAddElement(head, (REval *)fValue, fSize, this); return fNext->Shift(v, token, head); } else error("internal error 3"); return RSValue::Shift(v, token, head); } /* RSNrValue::Shift */
RState* RSStringValue::Shift(addr_t v, int32 token, RElem** head) { addr_t t = token; if (token == tIdent) { addr_t id = v; if (ResolveIdentifier(v)) t = tString; else error("Unknown identifier: %s", ST_Ident(id)); } if (t == tString || t == tRaw) { const char *s = (char *)v; int32 l; char *p; if (fKind == skHex) l = *(int32*)v; else l = strlen(s); int32 size = l; if (fSize > l) size = fSize; p = (char *)malloc(size + 2); memset(p, 0, size + 2); if (!p) error("Insufficient memory"); switch (fKind) { case skStr: memcpy(p, s, l); RAddElement(head, p, (fSize ? fSize : l), this); break; case skPStr: memcpy(p + 1, s, l); p[0] = l; RAddElement(head, p, (fSize ? fSize : l + 1), this); break; case skWStr: memcpy(p + 2, s, l); memcpy(p, &l, 2); RAddElement(head, p, (fSize ? fSize : l + 2), this); break; case skCStr: memcpy(p, s, l); RAddElement(head, p, (fSize ? fSize : l + 1), this); break; case skHex: memcpy(p, s + sizeof(int32), l); RAddElement(head, p, (fSize ? fSize : l), this); break; } // free(p); } else error("expected string"); return RState::Shift(v, token, head); } /* RSWStringValue::Shift */