← 输入框|github.com|刷新
Skip to content

The identifier char is not mangled in C backend #2359

Closed

Description

@Thirumalai-Shaktivel

MRE

char: str
char = ""
$ lpython examples/expr2.py --backend=c  
expr2__tmp__generated__.c:13:8: error: expected identifier or '('
char * char = NULL;
       ^
expr2__tmp__generated__.c:16:23: error: expected expression
    _lfortran_strcpy(&char, "", 1);
                      ^
2 errors generated.
The command 'gcc -o expr2.out expr2__tmp__generated__.c  -I /Users/thirumalai/Open_Source/lpython/src/bin/../libasr/runtime -L"/Users/thirumalai/Open_Source/lpython/src/bin/../runtime" -Wl,-rpath,"/Users/thirumalai/Open_Source/lpython/src/bin/../runtime" -llpython_runtime -lm' failed.

Activity

  1. added
    bug
    c
    on Oct 3, 2023
  2. tanay-man commented on Feb 14, 2024

    @tanay-man
    Contributor

    @Thirumalai-Shaktivel What should I replace the restricted keywords in C & C++ with?
    Will renaming them LFORTRAN_RESTRICTED_keyword be ok?

  3. Thirumalai-Shaktivel commented on Feb 17, 2024

    @Thirumalai-Shaktivel
    CollaboratorAuthor

    Nope, I think we need to recognise the keywords and mangle them, .i.e, if we see char, we need to replace it as _xx_char_xx or __xx_char or something that is less probable to be used. For this, I think we have to handle it in the unqiue_symbol pass or the C backend itself.

  4. certik commented on Feb 17, 2024

    @certik
    Contributor

    See https://lfortran.zulipchat.com/#narrow/stream/311866-LPython/topic/asr-.3Ec for the discussion about this. Indeed, enhancing the mangling pass is the way to go.

  5. tanay-man commented on Feb 18, 2024

    @tanay-man
    Contributor

    I have implemented this in PR #2546. I have only implemented the mangling for the C backend; the C++ backend is still pending.

  6. kmr-srbh commented on Apr 29, 2024

    @kmr-srbh
    Contributor

    @Thirumalai-Shaktivel this issue could be closed as #2546 was merged.

  7. Thirumalai-Shaktivel commented on Jun 16, 2024

    @Thirumalai-Shaktivel
    CollaboratorAuthor

    I following works, so closing this

    char: str
    char = "c"
    print (char)
    $ lpython examples/expr2.py
    c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugceasy to fix

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions