diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2023-09-02 21:17:18 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2023-12-08 17:34:50 +0000 |
commit | 06c3fb2749bda94cb5201f81ffdb8fa6c3161b2e (patch) | |
tree | 62f873df87c7c675557a179e0c4c83fe9f3087bc /contrib/llvm-project/clang/lib/AST/FormatString.cpp | |
parent | cf037972ea8863e2bab7461d77345367d2c1e054 (diff) | |
parent | 7fa27ce4a07f19b07799a767fc29416f3b625afb (diff) |
Diffstat (limited to 'contrib/llvm-project/clang/lib/AST/FormatString.cpp')
-rw-r--r-- | contrib/llvm-project/clang/lib/AST/FormatString.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/contrib/llvm-project/clang/lib/AST/FormatString.cpp b/contrib/llvm-project/clang/lib/AST/FormatString.cpp index c7dee2d421bb..ad5af9508983 100644 --- a/contrib/llvm-project/clang/lib/AST/FormatString.cpp +++ b/contrib/llvm-project/clang/lib/AST/FormatString.cpp @@ -351,10 +351,12 @@ ArgType::matchesType(ASTContext &C, QualType argTy) const { case AnyCharTy: { if (const auto *ETy = argTy->getAs<EnumType>()) { // If the enum is incomplete we know nothing about the underlying type. - // Assume that it's 'int'. + // Assume that it's 'int'. Do not use the underlying type for a scoped + // enumeration. if (!ETy->getDecl()->isComplete()) return NoMatch; - argTy = ETy->getDecl()->getIntegerType(); + if (ETy->isUnscopedEnumerationType()) + argTy = ETy->getDecl()->getIntegerType(); } if (const auto *BT = argTy->getAs<BuiltinType>()) { @@ -391,10 +393,11 @@ ArgType::matchesType(ASTContext &C, QualType argTy) const { case SpecificTy: { if (const EnumType *ETy = argTy->getAs<EnumType>()) { // If the enum is incomplete we know nothing about the underlying type. - // Assume that it's 'int'. + // Assume that it's 'int'. Do not use the underlying type for a scoped + // enumeration as that needs an exact match. if (!ETy->getDecl()->isComplete()) argTy = C.IntTy; - else + else if (ETy->isUnscopedEnumerationType()) argTy = ETy->getDecl()->getIntegerType(); } argTy = C.getCanonicalType(argTy).getUnqualifiedType(); @@ -848,6 +851,8 @@ bool FormatSpecifier::hasValidLengthModifier(const TargetInfo &Target, } switch (CS.getKind()) { + case ConversionSpecifier::bArg: + case ConversionSpecifier::BArg: case ConversionSpecifier::dArg: case ConversionSpecifier::DArg: case ConversionSpecifier::iArg: |