[PATCH] D156054: [Clang][Sema] DR722 (nullptr and varargs) and missing -Wvarargs diagnostics

2023-08-08 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added subscribers: jcranmer-intel, zahiraam. aaron.ballman added inline comments. Comment at: clang/lib/AST/FormatString.cpp:484-487 + if (const auto *PT = argTy->getAs()) { +if (PT->getPointeeType()->isCharType()) + return Match; + }

[PATCH] D156054: [Clang][Sema] DR722 (nullptr and varargs) and missing -Wvarargs diagnostics

2023-08-10 Thread Mital Ashok via Phabricator via cfe-commits
MitalAshok updated this revision to Diff 549176. MitalAshok added a comment. Address feedback; Reuse DefaultArgumentPromotion instead of duplicating its functionality when building VaArgExpr There is the added bonus for it working with dependent types somewhat (`template __builtin_va_arg(ap, T[

[PATCH] D156054: [Clang][Sema] DR722 (nullptr and varargs) and missing -Wvarargs diagnostics

2023-08-10 Thread Mital Ashok via Phabricator via cfe-commits
MitalAshok updated this revision to Diff 549177. MitalAshok added a comment. clang-format Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D156054/new/ https://reviews.llvm.org/D156054 Files: clang/docs/ReleaseNotes.rst clang/lib/AST/FormatString.

[PATCH] D156054: [Clang][Sema] DR722 (nullptr and varargs) and missing -Wvarargs diagnostics

2023-08-16 Thread Joshua Cranmer via Phabricator via cfe-commits
jcranmer-intel added inline comments. Comment at: clang/lib/Sema/SemaExpr.cpp:17317-17319 +if (TInfo->getType()->isSpecificBuiltinType(BuiltinType::Float) || +TInfo->getType()->isSpecificBuiltinType(BuiltinType::Half)) PromoteType = Context.DoubleTy; --

[PATCH] D156054: [Clang][Sema] DR722 (nullptr and varargs) and missing -Wvarargs diagnostics

2023-08-17 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment. Precommit CI still has a related failure, it seems. Comment at: clang/lib/Sema/SemaExpr.cpp:17317-17319 +if (TInfo->getType()->isSpecificBuiltinType(BuiltinType::Float) || +TInfo->getType()->isSpecificBuiltinType(BuiltinType::Half))

[PATCH] D156054: [Clang][Sema] DR722 (nullptr and varargs) and missing -Wvarargs diagnostics

2023-07-23 Thread Mital Ashok via Phabricator via cfe-commits
MitalAshok created this revision. Herald added a project: All. MitalAshok added a comment. MitalAshok added a reviewer: aaron.ballman. MitalAshok published this revision for review. Herald added subscribers: cfe-commits, wangpc. Herald added a project: clang. There is one observable difference by

[PATCH] D156054: [Clang][Sema] DR722 (nullptr and varargs) and missing -Wvarargs diagnostics

2023-07-25 Thread Mital Ashok via Phabricator via cfe-commits
MitalAshok updated this revision to Diff 544073. MitalAshok added a comment. Target clang 18 instead Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D156054/new/ https://reviews.llvm.org/D156054 Files: clang/docs/ReleaseNotes.rst clang/lib/Sema/S

[PATCH] D156054: [Clang][Sema] DR722 (nullptr and varargs) and missing -Wvarargs diagnostics

2023-08-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment. Thank you for working on this! FWIW, precommit Ci found a relevant test failure that should also be addressed. Comment at: clang/lib/Sema/SemaExpr.cpp:1062-1073 + // C2x 6.5.2.2p6: + // The integer promotions are performed on each trailing ar

[PATCH] D156054: [Clang][Sema] DR722 (nullptr and varargs) and missing -Wvarargs diagnostics

2023-08-04 Thread Mital Ashok via Phabricator via cfe-commits
MitalAshok updated this revision to Diff 547311. MitalAshok added a comment. No longer warn on printf("%p", nullptr) Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D156054/new/ https://reviews.llvm.org/D156054 Files: clang/docs/ReleaseNotes.rst

[PATCH] D156054: [Clang][Sema] DR722 (nullptr and varargs) and missing -Wvarargs diagnostics

2023-08-04 Thread Mital Ashok via Phabricator via cfe-commits
MitalAshok updated this revision to Diff 547353. MitalAshok added a comment. C99 7.15.1.1p2 explicitly allows a char* to be retrieved as a void* with va_arg, so the -Wformat-pedantic warning was incorrect. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.o

[PATCH] D156054: [Clang][Sema] DR722 (nullptr and varargs) and missing -Wvarargs diagnostics

2023-08-07 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment. Precommit CI found a related issue that should be addressed. Comment at: clang/www/cxx_dr_status.html:4376 Can nullptr be passed to an ellipsis? -Unknown +Clang 17 MitalAshok wrote: > It may be better to mark this

[PATCH] D156054: [Clang][Sema] DR722 (nullptr and varargs) and missing -Wvarargs diagnostics

2023-08-07 Thread Mital Ashok via Phabricator via cfe-commits
MitalAshok updated this revision to Diff 547874. MitalAshok marked an inline comment as done. MitalAshok added a comment. Fix scanf("%p", (char**)ptr) for -Wformat-pedantic Also added more tests for %p and -Wformat Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://revie

[PATCH] D156054: [Clang][Sema] DR722 (nullptr and varargs) and missing -Wvarargs diagnostics

2023-08-07 Thread Mital Ashok via Phabricator via cfe-commits
MitalAshok added inline comments. Comment at: clang/test/Sema/format-pointer.c:39 + printf("%p", np); + scanf("%p", &np); // expected-warning {{format specifies type 'void **' but the argument has type 'nullptr_t *'}} + scanf("%p", &npp); // pedantic-warning {{format specif

[PATCH] D156054: [Clang][Sema] DR722 (nullptr and varargs) and missing -Wvarargs diagnostics

2023-08-22 Thread Mital Ashok via Phabricator via cfe-commits
MitalAshok updated this revision to Diff 552356. MitalAshok added a comment. Use C's definition of type compatibility even in C++ mode (to not warn about enums promoted to their underlying types) Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D156054

[PATCH] D156054: [Clang][Sema] DR722 (nullptr and varargs) and missing -Wvarargs diagnostics

2023-08-22 Thread Mital Ashok via Phabricator via cfe-commits
MitalAshok updated this revision to Diff 552357. MitalAshok added a comment. clang-format Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D156054/new/ https://reviews.llvm.org/D156054 Files: clang/docs/ReleaseNotes.rst clang/lib/AST/ASTContext.cp

[PATCH] D156054: [Clang][Sema] DR722 (nullptr and varargs) and missing -Wvarargs diagnostics

2023-08-22 Thread Mital Ashok via Phabricator via cfe-commits
MitalAshok marked an inline comment as done. MitalAshok added inline comments. Comment at: clang/test/SemaCXX/varargs.cpp:34 enum Unscoped1 { One = 0x7FFF }; - (void)__builtin_va_arg(ap, Unscoped1); // ok + (void)__builtin_va_arg(ap, Unscoped1); // expected-warning {{sec

[PATCH] D156054: [Clang][Sema] DR722 (nullptr and varargs) and missing -Wvarargs diagnostics

2023-08-23 Thread Mital Ashok via Phabricator via cfe-commits
MitalAshok marked an inline comment as not done. MitalAshok added inline comments. Comment at: clang/test/SemaCXX/varargs.cpp:34 enum Unscoped1 { One = 0x7FFF }; - (void)__builtin_va_arg(ap, Unscoped1); // ok + (void)__builtin_va_arg(ap, Unscoped1); // expected-warning {

[PATCH] D156054: [Clang][Sema] DR722 (nullptr and varargs) and missing -Wvarargs diagnostics

2023-08-23 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments. Comment at: clang/test/SemaCXX/varargs.cpp:34 enum Unscoped1 { One = 0x7FFF }; - (void)__builtin_va_arg(ap, Unscoped1); // ok + (void)__builtin_va_arg(ap, Unscoped1); // expected-warning {{second argument to 'va_arg' is of promotable

[PATCH] D156054: [Clang][Sema] DR722 (nullptr and varargs) and missing -Wvarargs diagnostics

2023-08-24 Thread Mital Ashok via Phabricator via cfe-commits
MitalAshok updated this revision to Diff 553055. MitalAshok added a comment. enums now considered compatible with unsigned/signed versions of their underlying type for the purposes of -Wvarargs Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D156054/n

[PATCH] D156054: [Clang][Sema] DR722 (nullptr and varargs) and missing -Wvarargs diagnostics

2023-08-24 Thread Mital Ashok via Phabricator via cfe-commits
MitalAshok updated this revision to Diff 553056. MitalAshok added a comment. clang-format Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D156054/new/ https://reviews.llvm.org/D156054 Files: clang/docs/ReleaseNotes.rst clang/lib/AST/FormatString.

[PATCH] D156054: [Clang][Sema] DR722 (nullptr and varargs) and missing -Wvarargs diagnostics

2023-08-24 Thread Mital Ashok via Phabricator via cfe-commits
MitalAshok added inline comments. Comment at: clang/test/SemaCXX/varargs.cpp:34 enum Unscoped1 { One = 0x7FFF }; - (void)__builtin_va_arg(ap, Unscoped1); // ok + (void)__builtin_va_arg(ap, Unscoped1); // expected-warning {{second argument to 'va_arg' is of promotable ty

[PATCH] D156054: [Clang][Sema] DR722 (nullptr and varargs) and missing -Wvarargs diagnostics

2023-08-29 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment. I think this is looking close to good, just had some minor nits and an extra test case to consider. Comment at: clang/lib/Sema/SemaExpr.cpp:17255 + // Check if these are compatible types according to the C rules even in C++ + // because va_arg