ahatanak updated this revision to Diff 439574. ahatanak added a comment. Rebase
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D128373/new/ https://reviews.llvm.org/D128373 Files: clang/lib/AST/ASTContext.cpp clang/test/Sema/warn-memset-bad-sizeof.c Index: clang/test/Sema/warn-memset-bad-sizeof.c =================================================================== --- /dev/null +++ clang/test/Sema/warn-memset-bad-sizeof.c @@ -0,0 +1,15 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +// expected-no-diagnostics + +void *memset(void *, int, unsigned long); + +typedef struct { + int a; +} S; + +void test() { + S s; + __auto_type dstptr = &s; + memset(dstptr, 0, sizeof(s)); +} Index: clang/lib/AST/ASTContext.cpp =================================================================== --- clang/lib/AST/ASTContext.cpp +++ clang/lib/AST/ASTContext.cpp @@ -10323,11 +10323,11 @@ // Allow __auto_type to match anything; it merges to the type with more // information. if (const auto *AT = LHS->getAs<AutoType>()) { - if (AT->isGNUAutoType()) + if (!AT->isDeduced() && AT->isGNUAutoType()) return RHS; } if (const auto *AT = RHS->getAs<AutoType>()) { - if (AT->isGNUAutoType()) + if (!AT->isDeduced() && AT->isGNUAutoType()) return LHS; } return {};
Index: clang/test/Sema/warn-memset-bad-sizeof.c =================================================================== --- /dev/null +++ clang/test/Sema/warn-memset-bad-sizeof.c @@ -0,0 +1,15 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +// expected-no-diagnostics + +void *memset(void *, int, unsigned long); + +typedef struct { + int a; +} S; + +void test() { + S s; + __auto_type dstptr = &s; + memset(dstptr, 0, sizeof(s)); +} Index: clang/lib/AST/ASTContext.cpp =================================================================== --- clang/lib/AST/ASTContext.cpp +++ clang/lib/AST/ASTContext.cpp @@ -10323,11 +10323,11 @@ // Allow __auto_type to match anything; it merges to the type with more // information. if (const auto *AT = LHS->getAs<AutoType>()) { - if (AT->isGNUAutoType()) + if (!AT->isDeduced() && AT->isGNUAutoType()) return RHS; } if (const auto *AT = RHS->getAs<AutoType>()) { - if (AT->isGNUAutoType()) + if (!AT->isDeduced() && AT->isGNUAutoType()) return LHS; } return {};
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits