Skip to content

Commit

Permalink
fix Issue 21967 - importC: Error function without 'this' cannot be 'c…
Browse files Browse the repository at this point in the history
…onst'
  • Loading branch information
ibuclaw authored and thewilsonator committed May 26, 2021
1 parent c4f4306 commit 9cff437
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/dmd/cparse.d
Original file line number Diff line number Diff line change
Expand Up @@ -1426,7 +1426,14 @@ final class CParser(AST) : Parser!AST
break; // error recovery
}
if (specifier.mod & MOD.xconst)
dt = dt.addSTC(STC.const_);
{
// `const` is always applied to the return type, not the
// type function itself.
if (auto tf = dt.isTypeFunction())
tf.next = tf.next.addSTC(STC.const_);
else
dt = dt.addSTC(STC.const_);
}

if (!id) // no identifier
{
Expand Down
4 changes: 4 additions & 0 deletions test/compilable/imports/cstuff1.c
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,10 @@ typedef enum {
} TypedefEnum;
TypedefEnum typedef_var2;

/********************************/
// https://issues.dlang.org/show_bug.cgi?id=21967
const int const_int_fn(void);
const int *const_int_fn_ptr(void);

/********************************/

Expand Down

0 comments on commit 9cff437

Please sign in to comment.