llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

bad error message on incorrect string literal

Open llvmbot opened this issue 13 years ago • 7 comments

Bugzilla Link 17705
Version 3.2
OS Linux
Reporter LLVM Bugzilla Contributor
CC @DougGregor

Extended Description

linefeed should not be printed inside quotes. Instead error should be something like "invalid newline character in raw string delimiter".

5.cpp:1:21: error: invalid character '
' character in raw string delimiter; use PREFIX( )PREFIX to delimit raw string
char const* a = R"";
                    ^
5.cpp:1:17: error: expected expression
char const* a = R"";
                ^
2 errors generated.

llvmbot avatar Oct 27 '13 21:10 llvmbot

reproducer: https://godbolt.org/z/9o8Gxavjr

char const* a = R"
";

shafik avatar Jan 23 '24 02:01 shafik

The diagnostic is err_invalid_char_raw_delim

We issue it here:

https://github.com/llvm/llvm-project/blob/074630e8af94d839f6baf6378d7ed3d7a6d2753c/clang/lib/Lex/Lexer.cpp#L2229-L2230

I think a simple check for newline and maybe add a new diagnostic for this case invalid newline ....

shafik avatar Jan 26 '24 22:01 shafik

Hi!

This issue may be a good introductory issue for people new to working on LLVM. If you would like to work on this issue, your first steps are:

  1. In the comments of the issue, request for it to be assigned to you.
  2. Fix the issue locally.
  3. Run the test suite locally. Remember that the subdirectories under test/ create fine-grained testing targets, so you can e.g. use make check-clang-ast to only run Clang's AST tests.
  4. Create a Git commit.
  5. Run git clang-format HEAD~1 to format your changes.
  6. Open a pull request to the upstream repository on GitHub. Detailed instructions can be found in GitHub's documentation.

If you have any further questions about this issue, don't hesitate to ask via a comment in the thread below.

llvmbot avatar Jan 26 '24 22:01 llvmbot

@llvm/issue-subscribers-good-first-issue

Author: None (llvmbot)

| | | | --- | --- | | Bugzilla Link | [17705](https://llvm.org/bz17705) | | Version | 3.2 | | OS | Linux | | Reporter | LLVM Bugzilla Contributor | | CC | @DougGregor |

Extended Description

linefeed should not be printed inside quotes. Instead error should be something like "invalid newline character in raw string delimiter".

5.cpp:1:21: error: invalid character '
' character in raw string delimiter; use PREFIX( )PREFIX to delimit raw string
char const* a = R"";
                    ^
5.cpp:1:17: error: expected expression
char const* a = R"";
                ^
2 errors generated.

llvmbot avatar Jan 26 '24 22:01 llvmbot

@shafik, I will start analysing the issue.

akshaykumars614 avatar Feb 13 '24 19:02 akshaykumars614

Not merged yet.

EugeneZelenko avatar Feb 16 '24 00:02 EugeneZelenko

I have merged it now. Is it merged? Please close if it’s merged

akshaykumars614 avatar Feb 16 '24 01:02 akshaykumars614