Fix bug in default argument handling introduced in 540fc6c2f3
This commit is contained in:
17
decl.cpp
17
decl.cpp
@@ -486,16 +486,18 @@ Declarator::GetType(const Type *base, DeclSpecs *ds) const {
|
|||||||
if (d->declarators.size()) {
|
if (d->declarators.size()) {
|
||||||
// Try to find an initializer expression.
|
// Try to find an initializer expression.
|
||||||
Declarator *decl = d->declarators[0];
|
Declarator *decl = d->declarators[0];
|
||||||
while (decl->child != NULL) {
|
while (decl != NULL) {
|
||||||
if (decl->initExpr != NULL) {
|
if (decl->initExpr != NULL) {
|
||||||
decl->initExpr = TypeCheck(decl->initExpr);
|
decl->initExpr = TypeCheck(decl->initExpr);
|
||||||
decl->initExpr = Optimize(decl->initExpr);
|
decl->initExpr = Optimize(decl->initExpr);
|
||||||
if (decl->initExpr != NULL &&
|
if (decl->initExpr != NULL) {
|
||||||
((init = dynamic_cast<ConstExpr *>(decl->initExpr)) == NULL) &&
|
init = dynamic_cast<ConstExpr *>(decl->initExpr);
|
||||||
((init = dynamic_cast<NullPointerExpr *>(decl->initExpr)) == NULL)) {
|
if (init == NULL)
|
||||||
Error(decl->initExpr->pos, "Default value for parameter "
|
init = dynamic_cast<NullPointerExpr *>(decl->initExpr);
|
||||||
"\"%s\" must be a compile-time constant.",
|
if (init == NULL)
|
||||||
sym->name.c_str());
|
Error(decl->initExpr->pos, "Default value for parameter "
|
||||||
|
"\"%s\" must be a compile-time constant.",
|
||||||
|
sym->name.c_str());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -511,6 +513,7 @@ Declarator::GetType(const Type *base, DeclSpecs *ds) const {
|
|||||||
Error(pos, "No return type provided in function declaration.");
|
Error(pos, "No return type provided in function declaration.");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dynamic_cast<const FunctionType *>(returnType) != NULL) {
|
if (dynamic_cast<const FunctionType *>(returnType) != NULL) {
|
||||||
Error(pos, "Illegal to return function type from function.");
|
Error(pos, "Illegal to return function type from function.");
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|||||||
Reference in New Issue
Block a user