diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp --- a/clang/lib/AST/ASTContext.cpp +++ b/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()) { - if (AT->isGNUAutoType()) + if (!AT->isDeduced() && AT->isGNUAutoType()) return RHS; } if (const auto *AT = RHS->getAs()) { - if (AT->isGNUAutoType()) + if (!AT->isDeduced() && AT->isGNUAutoType()) return LHS; } return {}; diff --git a/clang/test/Sema/warn-memset-bad-sizeof.c b/clang/test/Sema/warn-memset-bad-sizeof.c new file mode 100644 --- /dev/null +++ b/clang/test/Sema/warn-memset-bad-sizeof.c @@ -0,0 +1,16 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +// expected-no-diagnostics + +typedef __SIZE_TYPE__ size_t; +void *memset(void *, int, size_t); + +typedef struct { + int a; +} S; + +void test() { + S s; + __auto_type dstptr = &s; + memset(dstptr, 0, sizeof(s)); +}