https://github.com/Sirraide created https://github.com/llvm/llvm-project/pull/188910
I forgot to check for dependent types in #187828; we somehow didn’t have tests for this so CI didn’t catch this... >From e15841488c0cc8a3eec0b4a1357c646c0272141b Mon Sep 17 00:00:00 2001 From: Sirraide <[email protected]> Date: Fri, 27 Mar 2026 06:10:14 +0100 Subject: [PATCH] [Clang] [Sema] Don't diagnose multidimensional subscript operators on dependent types --- clang/lib/Sema/SemaExpr.cpp | 3 ++- clang/test/SemaCXX/cxx23-builtin-subscript.cpp | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index cbbb4f791ee80..4856a51aa6a0d 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -5173,7 +5173,8 @@ ExprResult Sema::ActOnArraySubscriptExpr(Scope *S, Expr *base, // Issue a better diagnostic if we tried to pass multiple arguments to // a builtin subscript operator rather than diagnosing this as a generic // overload resolution failure. - if (ArgExprs.size() != 1 && !base->getType()->isRecordType() && + if (ArgExprs.size() != 1 && !base->getType()->isDependentType() && + !base->getType()->isRecordType() && !base->getType()->isObjCObjectPointerType()) { Diag(base->getExprLoc(), diag::err_ovl_builtin_subscript_expects_single_arg) << base->getType() << base->getSourceRange(); diff --git a/clang/test/SemaCXX/cxx23-builtin-subscript.cpp b/clang/test/SemaCXX/cxx23-builtin-subscript.cpp index 8067663ded676..09602cf49bf1e 100644 --- a/clang/test/SemaCXX/cxx23-builtin-subscript.cpp +++ b/clang/test/SemaCXX/cxx23-builtin-subscript.cpp @@ -62,3 +62,6 @@ void f() { p.three[1, 2][3] = 4; // expected-error {{property subscript expects exactly one argument}} p.three[1][2, 3] = 4; // expected-error {{property subscript expects exactly one argument}} } + +template<class T> +void dependent(T x) { x[0, 0]; } _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
