diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2016-08-20 16:51:33 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2016-08-20 16:51:33 +0000 |
commit | f3b323debc949cf67cb395337fc0d5d5b26c21b9 (patch) | |
tree | d53992293b16f139b66f2effb259cbf0a057f031 /clang/lib/Analysis/ScanfFormatString.cpp | |
parent | f9fd63ad39936968e5b81a5ad5d269ffa761604c (diff) | |
download | llvm-f3b323debc949cf67cb395337fc0d5d5b26c21b9.zip llvm-f3b323debc949cf67cb395337fc0d5d5b26c21b9.tar.gz llvm-f3b323debc949cf67cb395337fc0d5d5b26c21b9.tar.bz2 |
[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
Diffstat (limited to 'clang/lib/Analysis/ScanfFormatString.cpp')
-rw-r--r-- | clang/lib/Analysis/ScanfFormatString.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/clang/lib/Analysis/ScanfFormatString.cpp b/clang/lib/Analysis/ScanfFormatString.cpp index 82b0388..3b93f1a 100644 --- a/clang/lib/Analysis/ScanfFormatString.cpp +++ b/clang/lib/Analysis/ScanfFormatString.cpp @@ -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) |