summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRenato Filho <renato.filho@openbossa.org>2010-06-09 16:59:20 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-09 19:10:05 -0300
commitcf3a3e20dd430274e88fcec8b683d8bac42a5785 (patch)
tree5911a647548fc2b264178250c4352ed088ded905
parent3e2500cab4c5a8b0bd0fb532ca6ed155c36c6dd5 (diff)
Only display warning for unnamed arguments when this argument has
default value.
-rw-r--r--abstractmetabuilder.cpp19
-rw-r--r--abstractmetalang.cpp3
-rw-r--r--tests/testmodifyfunction.cpp2
3 files changed, 9 insertions, 15 deletions
diff --git a/abstractmetabuilder.cpp b/abstractmetabuilder.cpp
index 2fb50632..a2e771c9 100644
--- a/abstractmetabuilder.cpp
+++ b/abstractmetabuilder.cpp
@@ -1658,6 +1658,7 @@ AbstractMetaFunction* AbstractMetaBuilder::traverseFunction(FunctionModelItem fu
if (m_currentClass)
replacedExpression = metaFunction->replacedDefaultExpression(m_currentClass, i + 1);
+ bool hasDefaultValue = false;
if (arg->defaultValue() || !replacedExpression.isEmpty()) {
QString expr = arg->defaultValueExpression();
expr = fixDefaultValue(arg, metaArg->type(), metaFunction, m_currentClass, i);
@@ -1675,25 +1676,17 @@ AbstractMetaFunction* AbstractMetaBuilder::traverseFunction(FunctionModelItem fu
if (metaArg->type()->isEnum() || metaArg->type()->isFlags())
m_enumDefaultArguments << QPair<AbstractMetaArgument *, AbstractMetaFunction *>(metaArg, metaFunction);
+
+ hasDefaultValue = !expr.isEmpty();
}
//Check for missing argument name
- if (!metaArg->hasName() && !metaFunction->isOperatorOverload() && metaFunction->argumentName(i, false, m_currentClass).isEmpty())
- ReportHandler::warning(QString("Argument %1 on function '%2::%3' declared without name.").arg(i).arg(className).arg(functionItem->name()));
+ if (hasDefaultValue && !metaArg->hasName() && !metaFunction->isOperatorOverload() && metaFunction->argumentName(i+1, false, m_currentClass).isEmpty()) {
+ ReportHandler::warning(QString("Argument %1 on function '%2::%3' has default expressiont but does not have name.").arg(i+1).arg(className).arg(functionItem->name()));
+ }
}
-#if 0
- // If we where not able to translate the default argument make it
- // reset all default arguments before this one too.
- for (int i = 0; i < first_default_argument; ++i)
- meta_arguments[i]->setDefaultValueExpression("<x>" + QString());
-
- if (ReportHandler::debugLevel() == ReportHandler::FullDebug)
- foreach (AbstractMetaArgument *arg, meta_arguments)
- ReportHandler::debugFull(" - " + arg->toString());
-#endif
-
return metaFunction;
}
diff --git a/abstractmetalang.cpp b/abstractmetalang.cpp
index 4a757135..fd9716f7 100644
--- a/abstractmetalang.cpp
+++ b/abstractmetalang.cpp
@@ -703,8 +703,9 @@ QString AbstractMetaFunction::argumentName(int index, bool create, const Abstrac
{
foreach (FunctionModification mod, modifications(implementor)) {
foreach (ArgumentModification argMod, mod.argument_mods) {
- if ((argMod.index == index) && !argMod.renamed_to.isEmpty())
+ if ((argMod.index == index) && !argMod.renamed_to.isEmpty()) {
return argMod.renamed_to;
+ }
}
}
diff --git a/tests/testmodifyfunction.cpp b/tests/testmodifyfunction.cpp
index 930ccdca..95ba16f4 100644
--- a/tests/testmodifyfunction.cpp
+++ b/tests/testmodifyfunction.cpp
@@ -29,7 +29,7 @@ void TestModifyFunction::testRenameArgument()
{
const char* cppCode ="\
struct A {\
- void method(int myarg);\
+ void method(int=0);\
};\
";
const char* xmlCode = "\