diff options
| author | David Majnemer <david.majnemer@gmail.com> | 2015-04-09 19:53:25 +0000 |
|---|---|---|
| committer | David Majnemer <david.majnemer@gmail.com> | 2015-04-09 19:53:25 +0000 |
| commit | df8f73fd8ae0aff10e456ec7317f20c997b195ce (patch) | |
| tree | 386b349fae03f89a112cb95c5323700e379bc699 /clang | |
| parent | bba0eaae076899981c56069aed9d3df89f11477f (diff) | |
| download | bcm5719-llvm-df8f73fd8ae0aff10e456ec7317f20c997b195ce.tar.gz bcm5719-llvm-df8f73fd8ae0aff10e456ec7317f20c997b195ce.zip | |
[Sema] Diagnose references to unbound arrays in function definitions
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.
llvm-svn: 234528
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/lib/Sema/SemaChecking.cpp | 4 | ||||
| -rw-r--r-- | clang/test/SemaCXX/vla.cpp | 3 |
2 files changed, 7 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp index e557c50e027..d4390e53f0b 100644 --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -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; diff --git a/clang/test/SemaCXX/vla.cpp b/clang/test/SemaCXX/vla.cpp index dae6450553a..6efb648e786 100644 --- a/clang/test/SemaCXX/vla.cpp +++ b/clang/test/SemaCXX/vla.cpp @@ -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}} +} |

