summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDeclCXX.cpp
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2010-05-04 01:53:42 +0000
committerJohn McCall <rjmccall@apple.com>2010-05-04 01:53:42 +0000
commite61b02bcaf8a21d1507348b1a411b8f94091a328 (patch)
tree570ab72fed3139597e14e8b1a3907afb5ad2f531 /clang/lib/Sema/SemaDeclCXX.cpp
parent70a3b1219342d7dcd6e88e3ea47d28a2e90961b1 (diff)
downloadbcm5719-llvm-e61b02bcaf8a21d1507348b1a411b8f94091a328.tar.gz
bcm5719-llvm-e61b02bcaf8a21d1507348b1a411b8f94091a328.zip
When inheriting a default argument expression, inherit the full expression,
not just the inner expression. This is important if the expression has any temporaries. Fixes PR 7028. Basically a symptom of really tragic method names. llvm-svn: 102998
Diffstat (limited to 'clang/lib/Sema/SemaDeclCXX.cpp')
-rw-r--r--clang/lib/Sema/SemaDeclCXX.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index c4467850c93..6259b85af48 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -298,13 +298,15 @@ bool Sema::MergeCXXFunctionDecl(FunctionDecl *New, FunctionDecl *Old) {
<< OldParam->getDefaultArgRange();
Invalid = true;
} else if (OldParam->hasDefaultArg()) {
- // Merge the old default argument into the new parameter
+ // Merge the old default argument into the new parameter.
+ // It's important to use getInit() here; getDefaultArg()
+ // strips off any top-level CXXExprWithTemporaries.
NewParam->setHasInheritedDefaultArg();
if (OldParam->hasUninstantiatedDefaultArg())
NewParam->setUninstantiatedDefaultArg(
OldParam->getUninstantiatedDefaultArg());
else
- NewParam->setDefaultArg(OldParam->getDefaultArg());
+ NewParam->setDefaultArg(OldParam->getInit());
} else if (NewParam->hasDefaultArg()) {
if (New->getDescribedFunctionTemplate()) {
// Paragraph 4, quoted above, only applies to non-template functions.
OpenPOWER on IntegriCloud