[PATCH] Fix for http://llvm.org/PR21915: Assertion Failed on multidimensional VLA in function arguments.

John McCall rjmccall at gmail.com
Mon Dec 15 14:01:48 PST 2014


================
Comment at: lib/CodeGen/CodeGenFunction.h:2753
@@ +2752,3 @@
+        QualType ActualBaseType = ActualArgType;
+        while (ArgBaseType->isPointerType() &&
+               ActualBaseType->isPointerType()) {
----------------
Pointers aren't the only variably-modified type; you need to be able to look through functions types as well.  Something like::
  size_t test(int n, int (*(*fn)(void))[n])
And you're not looking through references, either.

But why not just have an exception for any variably-modified type?

================
Comment at: lib/CodeGen/CodeGenFunction.h:2757
@@ -2756,1 +2756,3 @@
+              ActualBaseType->getAs<PointerType>()->getPointeeType();
+          ArgBaseType = ArgBaseType->getAs<PointerType>()->getPointeeType();
           if (ArgBaseType->isVariableArrayType()) {
----------------
If you do keep this code, use castAs<> for casts that you know will succeed.

http://reviews.llvm.org/D6655

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the cfe-commits mailing list