[Sema] Don't crash on scanf on forward-declared enums.
This is valid in GNU C, which allows pointers to incomplete enums. GCC just pretends that the underlying type is 'int' in those cases, follow that behavior. llvm-svn: 279374
This commit is contained in:
@@ -418,8 +418,12 @@ bool ScanfSpecifier::fixType(QualType QT, QualType RawQT,
|
||||
QualType PT = QT->getPointeeType();
|
||||
|
||||
// If it's an enum, get its underlying type.
|
||||
if (const EnumType *ETy = PT->getAs<EnumType>())
|
||||
if (const EnumType *ETy = PT->getAs<EnumType>()) {
|
||||
// Don't try to fix incomplete enums.
|
||||
if (!ETy->getDecl()->isComplete())
|
||||
return false;
|
||||
PT = ETy->getDecl()->getIntegerType();
|
||||
}
|
||||
|
||||
const BuiltinType *BT = PT->getAs<BuiltinType>();
|
||||
if (!BT)
|
||||
|
||||
Reference in New Issue
Block a user