]> granicus.if.org Git - clang/commitdiff
[Sema] Diagnose references to unbound arrays in function definitions
authorDavid Majnemer <david.majnemer@gmail.com>
Thu, 9 Apr 2015 19:53:25 +0000 (19:53 +0000)
committerDavid Majnemer <david.majnemer@gmail.com>
Thu, 9 Apr 2015 19:53:25 +0000 (19:53 +0000)
A [*] is only allowed in a declaration for a function, not in its
definition.  We didn't correctly recurse on reference types while
looking for it, causing us to crash in CodeGen instead of rejecting it.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@234528 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaChecking.cpp
test/SemaCXX/vla.cpp

index e557c50e027332220788e710d76f65276f82c7fe..d4390e53f0bcbd84dded6f1b6039acd519208f48 100644 (file)
@@ -7713,6 +7713,10 @@ static void diagnoseArrayStarInParamType(Sema &S, QualType PType,
     diagnoseArrayStarInParamType(S, PointerTy->getPointeeType(), Loc);
     return;
   }
+  if (const auto *ReferenceTy = dyn_cast<ReferenceType>(PType)) {
+    diagnoseArrayStarInParamType(S, ReferenceTy->getPointeeType(), Loc);
+    return;
+  }
   if (const auto *ParenTy = dyn_cast<ParenType>(PType)) {
     diagnoseArrayStarInParamType(S, ParenTy->getInnerType(), Loc);
     return;
index dae6450553aa364f53ccdcce51a5762a3dac2fcd..6efb648e7868da60cafeff13a0348a1d23506970 100644 (file)
@@ -17,3 +17,6 @@ namespace PR18581 {
     incomplete c[n]; // expected-error {{incomplete}}
   }
 }
+
+void pr23151(int (&)[*]) { // expected-error {{variable length array must be bound in function definition}}
+}