Fix crash caused by unnamed union or struct when doing ast-print

llvm-svn: 211380
This commit is contained in:
Serge Pavlov 2014-06-20 17:08:28 +00:00
parent 5ec80c2a85
commit eb57aa65dc
2 changed files with 17 additions and 3 deletions

View File

@ -1274,10 +1274,12 @@ void StmtPrinter::VisitDesignatedInitExpr(DesignatedInitExpr *Node) {
DEnd = Node->designators_end();
D != DEnd; ++D) {
if (D->isFieldDesignator()) {
if (D->getDotLoc().isInvalid())
OS << D->getFieldName()->getName() << ":";
else
if (D->getDotLoc().isInvalid()) {
if (IdentifierInfo *II = D->getFieldName())
OS << II->getName() << ":";
} else {
OS << "." << D->getFieldName()->getName();
}
} else {
OS << "[";
if (D->isArrayDesignator()) {

View File

@ -196,3 +196,15 @@ struct s11 {
} f0;
int f1;
};
// Unnamed structures.
struct s12 {
struct {
unsigned char aa;
unsigned char bb;
};
};
void f11() {
struct s12 var = { .aa = 33 };
}