Skip to content

Commit

Permalink
A Fortran enumerator may be an argument of a function call
Browse files Browse the repository at this point in the history
  • Loading branch information
smateo committed May 8, 2018
1 parent a1b829d commit 20d4a9e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/frontend/fortran/fortran03-exprtype.c
Original file line number Diff line number Diff line change
Expand Up @@ -4425,10 +4425,11 @@ static void check_symbol_of_argument(AST sym, const decl_context_t* decl_context
}
}
}
if (entry == NULL ||

if (entry == NULL ||
(entry->kind != SK_VARIABLE &&
entry->kind != SK_FUNCTION &&
entry->kind != SK_FUNCTION &&
entry->kind != SK_ENUMERATOR &&
entry->kind != SK_UNDEFINED))
{
error_printf_at(ast_get_locus(sym), "'%s' cannot be an argument\n", entry->symbol_name);
Expand All @@ -4439,6 +4440,19 @@ static void check_symbol_of_argument(AST sym, const decl_context_t* decl_context
{
check_symbol_name_as_a_variable(sym, entry, decl_context, nodecl_output);
}
else if (entry->kind == SK_ENUMERATOR)
{
if (nodecl_is_null(entry->value)
|| !nodecl_is_constant(entry->value))
{
error_printf_at(ast_get_locus(sym), "'%s' is not a valid enumerator\n", entry->symbol_name);
*nodecl_output = nodecl_make_err_expr(ast_get_locus(sym));
return;
}

// Use the constant value instead
*nodecl_output = fortran_const_value_to_nodecl(nodecl_get_constant(entry->value));
}
else if (entry->kind == SK_FUNCTION)
{
*nodecl_output = nodecl_make_symbol(entry, ast_get_locus(sym));
Expand Down
2 changes: 2 additions & 0 deletions tests/01_fortran.dg/success_modules_081.F90
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ MODULE M
ENUM, BIND(C)
ENUMERATOR :: E1
END ENUM

INTEGER(KIND(E1)) :: VAR = 0
END MODULE M

0 comments on commit 20d4a9e

Please sign in to comment.