[clang] 66fa284 - [clang] Ignore DependentSizeArray in -Warray-parameter
via cfe-commits
cfe-commits at lists.llvm.org
Wed Jul 13 05:58:33 PDT 2022
Author: serge-sans-paille
Date: 2022-07-13T14:58:23+02:00
New Revision: 66fa2847a775dda27ddcac3832769441727db42f
URL: https://github.com/llvm/llvm-project/commit/66fa2847a775dda27ddcac3832769441727db42f
DIFF: https://github.com/llvm/llvm-project/commit/66fa2847a775dda27ddcac3832769441727db42f.diff
LOG: [clang] Ignore DependentSizeArray in -Warray-parameter
Acknowledge we don't know how to handle those yet.
Added:
Modified:
clang/lib/Sema/SemaDecl.cpp
clang/test/Sema/array-parameter.cpp
Removed:
################################################################################
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 982fbf2203f79..b5fa64713fb86 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -3241,9 +3241,15 @@ static bool EquivalentArrayTypes(QualType Old, QualType New,
}
// Only compare size, ignore Size modifiers and CVR.
- if (Old->isConstantArrayType() && New->isConstantArrayType())
+ if (Old->isConstantArrayType() && New->isConstantArrayType()) {
return Ctx.getAsConstantArrayType(Old)->getSize() ==
Ctx.getAsConstantArrayType(New)->getSize();
+ }
+
+ // Don't try to compare dependent sized array
+ if (Old->isDependentSizedArrayType() && New->isDependentSizedArrayType()) {
+ return true;
+ }
return Old == New;
}
diff --git a/clang/test/Sema/array-parameter.cpp b/clang/test/Sema/array-parameter.cpp
index 6842226c71ea7..14cc88f2e36cb 100644
--- a/clang/test/Sema/array-parameter.cpp
+++ b/clang/test/Sema/array-parameter.cpp
@@ -16,3 +16,10 @@ void func<10>(int (&Val)[10]) {
static constexpr int Extent = 10;
void funk(int i[10]);
void funk(int i[Extent]); // no-warning
+
+template<int K>
+struct T {
+ static void F(int a[8 * K]);
+};
+template<int K>
+void T<K>::F(int a[8 * K]) {} // no-warning
More information about the cfe-commits
mailing list