diff options
| -rw-r--r-- | clang/lib/CodeGen/CGExprScalar.cpp | 4 | ||||
| -rw-r--r-- | clang/test/CodeGen/variable-array.c | 7 |
2 files changed, 11 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CGExprScalar.cpp b/clang/lib/CodeGen/CGExprScalar.cpp index 98c41e24b6a..0c6e6c6854c 100644 --- a/clang/lib/CodeGen/CGExprScalar.cpp +++ b/clang/lib/CodeGen/CGExprScalar.cpp @@ -725,6 +725,10 @@ ScalarExprEmitter::VisitSizeOfAlignOfExpr(const SizeOfAlignOfExpr *E) { if (E->isArgumentType()) { // sizeof(type) - make sure to emit the VLA size. CGF.EmitVLASize(TypeToSize); + } else { + // C99 6.5.3.4p2: If the argument is an expression of type + // VLA, it is evaluated. + CGF.EmitAnyExpr(E->getArgumentExpr()); } return CGF.GetVLASize(VAT); diff --git a/clang/test/CodeGen/variable-array.c b/clang/test/CodeGen/variable-array.c new file mode 100644 index 00000000000..280539fa897 --- /dev/null +++ b/clang/test/CodeGen/variable-array.c @@ -0,0 +1,7 @@ +// RUN: clang-cc -emit-llvm < %s | grep puts + +int a(int x) +{ + int (*y)[x]; + return sizeof(*(puts("asdf"),y)); +} |

