diff options
| author | Serge Pavlov <sepavloff@gmail.com> | 2016-06-14 02:55:56 +0000 |
|---|---|---|
| committer | Serge Pavlov <sepavloff@gmail.com> | 2016-06-14 02:55:56 +0000 |
| commit | b82a9401dfb76131c83f9bb441bf624c1ae7cc7f (patch) | |
| tree | 57f94c31620c257045a351f953125b3fbda6c52e /clang/lib/Sema/SemaExpr.cpp | |
| parent | 84685fc8310e89136409a43846dc1018e5a88489 (diff) | |
| download | bcm5719-llvm-b82a9401dfb76131c83f9bb441bf624c1ae7cc7f.tar.gz bcm5719-llvm-b82a9401dfb76131c83f9bb441bf624c1ae7cc7f.zip | |
Detect recursive default argument definition
If definition of default function argument uses itself, clang crashed,
because corresponding function parameter is not associated with the default
argument yet. With this fix clang emits appropriate error message.
This change fixes PR28105.
Differential Revision: http://reviews.llvm.org/D21301
llvm-svn: 272623
Diffstat (limited to 'clang/lib/Sema/SemaExpr.cpp')
| -rw-r--r-- | clang/lib/Sema/SemaExpr.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index f766091e54e..f617db91510 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -4566,6 +4566,13 @@ ExprResult Sema::BuildCXXDefaultArgExpr(SourceLocation CallLoc, } } + // If the default argument expression is not set yet, we are building it now. + if (!Param->hasInit()) { + Diag(Param->getLocStart(), diag::err_recursive_default_argument) << FD; + Param->setInvalidDecl(); + return ExprError(); + } + // If the default expression creates temporaries, we need to // push them to the current stack of expression temporaries so they'll // be properly destroyed. |

