Author: Timm Bäder Date: 2024-07-14T07:32:42+02:00 New Revision: 92fe3911c3e0f5e76cf60c8b3203002e6e6aa047
URL: https://github.com/llvm/llvm-project/commit/92fe3911c3e0f5e76cf60c8b3203002e6e6aa047 DIFF: https://github.com/llvm/llvm-project/commit/92fe3911c3e0f5e76cf60c8b3203002e6e6aa047.diff LOG: [clang][Interp] Reject non-pointer typed dummies This happens a lot for NonTypeTemplateParm decls. Added: Modified: clang/lib/AST/Interp/Compiler.cpp clang/test/AST/Interp/literals.cpp Removed: ################################################################################ diff --git a/clang/lib/AST/Interp/Compiler.cpp b/clang/lib/AST/Interp/Compiler.cpp index 209fb54ecdcb..0b2a38d02b4a 100644 --- a/clang/lib/AST/Interp/Compiler.cpp +++ b/clang/lib/AST/Interp/Compiler.cpp @@ -5094,9 +5094,10 @@ bool Compiler<Emitter>::visitDeclRef(const ValueDecl *D, const Expr *E) { if (E->getType()->isVoidType()) return true; // Convert the dummy pointer to another pointer type if we have to. - if (PrimType PT = classifyPrim(E); PT != PT_Ptr && isPtrType(PT)) { - if (!this->emitDecayPtr(PT_Ptr, PT, E)) - return false; + if (PrimType PT = classifyPrim(E); PT != PT_Ptr) { + if (isPtrType(PT)) + return this->emitDecayPtr(PT_Ptr, PT, E); + return false; } return true; } diff --git a/clang/test/AST/Interp/literals.cpp b/clang/test/AST/Interp/literals.cpp index 630d9b53cca2..1f2755e710e3 100644 --- a/clang/test/AST/Interp/literals.cpp +++ b/clang/test/AST/Interp/literals.cpp @@ -1276,3 +1276,17 @@ namespace ComparisonAgainstOnePastEnd { static_assert(&a + 1 == &b + 1, ""); // both-error {{static assertion failed}} }; + +namespace NTTP { + template <typename _Tp, unsigned _Nm> + constexpr unsigned + size(const _Tp (&)[_Nm]) noexcept + { return _Nm; } + + template <char C> + static int write_padding() { + static const char Chars[] = {C}; + + return size(Chars); + } +} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits