[PATCH] D156596: [Clang] Produce a warning instead of an error in unevaluated strings before C++26

2023-08-10 Thread Corentin Jabot via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG20e01167b15a: [Clang] Produce a warning instead of an error 
in unevaluated strings before… (authored by cor3ntin).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D156596/new/

https://reviews.llvm.org/D156596

Files:
  clang/include/clang/Basic/DiagnosticLexKinds.td
  clang/lib/Lex/LiteralSupport.cpp
  clang/test/CXX/dcl.dcl/dcl.link/p2.cpp
  clang/test/CXX/dcl.dcl/p4-0x.cpp
  clang/test/FixIt/unevaluated-strings.cpp
  clang/test/Sema/static-assert.c
  clang/test/SemaCXX/static-assert.cpp

Index: clang/test/SemaCXX/static-assert.cpp
===
--- clang/test/SemaCXX/static-assert.cpp
+++ clang/test/SemaCXX/static-assert.cpp
@@ -29,13 +29,19 @@
 S s1; // expected-note {{in instantiation of template class 'S' requested here}}
 S s2;
 
-static_assert(false, L"\x"); // expected-error {{an unevaluated string literal cannot have an encoding prefix}} \
- // expected-error {{invalid escape sequence '\x' in an unevaluated string literal}}
-static_assert(false, u"\U000317FF"); // expected-error {{an unevaluated string literal cannot have an encoding prefix}}
-// FIXME: render this as u8"\u03A9"
-static_assert(false, u8"Ω"); // expected-error {{an unevaluated string literal cannot have an encoding prefix}}
-static_assert(false, L"\u1234"); // expected-error {{an unevaluated string literal cannot have an encoding prefix}}
-static_assert(false, L"\x1ff"// expected-error {{an unevaluated string literal cannot have an encoding prefix}} \
+static_assert(false, L"\x"); // expected-warning {{encoding prefix 'L' on an unevaluated string literal has no effect and is incompatible with c++2c}} \
+ // expected-error {{invalid escape sequence '\x' in an unevaluated string literal}} \
+ // expected-error {{hex escape sequence out of range}}
+static_assert(false, u"\U000317FF"); // expected-warning {{encoding prefix 'u' on an unevaluated string literal has no effect and is incompatible with c++2c}} \
+ // expected-error {{static assertion failed}}
+
+static_assert(false, u8"Ω"); // expected-warning {{encoding prefix 'u8' on an unevaluated string literal has no effect and is incompatible with c++2c}} \
+ // expected-error {{static assertion failed: Ω}}
+static_assert(false, L"\u1234"); // expected-warning {{encoding prefix 'L' on an unevaluated string literal has no effect and is incompatible with c++2c}} \
+ // expected-error {{static assertion failed: ሴ}}
+
+static_assert(false, L"\x1ff"// expected-warning {{encoding prefix 'L' on an unevaluated string literal has no effect and is incompatible with c++2c}} \
+ // expected-error {{hex escape sequence out of range}} \
  // expected-error {{invalid escape sequence '\x1ff' in an unevaluated string literal}}
  "0\x123"// expected-error {{invalid escape sequence '\x123' in an unevaluated string literal}}
  "fx\xf" // expected-error {{invalid escape sequence '\xf' in an unevaluated string literal}}
Index: clang/test/Sema/static-assert.c
===
--- clang/test/Sema/static-assert.c
+++ clang/test/Sema/static-assert.c
@@ -94,3 +94,20 @@
 // __builtin_strlen(literal) is considered an integer constant expression
 // and doesn't cause a pedantic warning
 #endif
+
+
+_Static_assert(0, L"\x"); // expected-warning {{encoding prefix 'L' on an unevaluated string literal has no effect}} \
+  // expected-error {{invalid escape sequence '\x' in an unevaluated string literal}} \
+  // expected-error {{hex escape sequence out of range}} \
+  // ext-warning {{'_Static_assert' is a C11 extension}}
+_Static_assert(0, L"\u1234"); // expected-warning {{encoding prefix 'L' on an unevaluated string literal has no effect}} \
+  // expected-error {{static assertion failed: ሴ}} \
+  // ext-warning {{'_Static_assert' is a C11 extension}}
+
+_Static_assert(0, L"\x1ff"  // expected-warning {{encoding prefix 'L' on an unevaluated string literal has no effect}} \
+// expected-error {{hex escape sequence out of range}} \
+// expected-error {{invalid escape sequence '\x1ff' in an unevaluated string literal}} \
+// ext-warning {{'_Static_assert' is a C11 extension}}
+   "0\x123" // expected-error {{invalid escape 

[PATCH] D156596: [Clang] Produce a warning instead of an error in unevaluated strings before C++26

2023-08-09 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast accepted this revision.
hubert.reinterpretcast added a comment.

In D156596#4573354 , @aaron.ballman 
wrote:

> LGTM but please wait for @hubert.reinterpretcast to confirm the new tests 
> cover what he was looking for.

LGTM; thanks!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D156596/new/

https://reviews.llvm.org/D156596

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D156596: [Clang] Produce a warning instead of an error in unevaluated strings before C++26

2023-08-09 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM but please wait for @hubert.reinterpretcast to confirm the new tests cover 
what he was looking for.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D156596/new/

https://reviews.llvm.org/D156596

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D156596: [Clang] Produce a warning instead of an error in unevaluated strings before C++26

2023-08-09 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 548503.
cor3ntin added a comment.

Add C tests


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D156596/new/

https://reviews.llvm.org/D156596

Files:
  clang/include/clang/Basic/DiagnosticLexKinds.td
  clang/lib/Lex/LiteralSupport.cpp
  clang/test/CXX/dcl.dcl/dcl.link/p2.cpp
  clang/test/CXX/dcl.dcl/p4-0x.cpp
  clang/test/FixIt/unevaluated-strings.cpp
  clang/test/Sema/static-assert.c
  clang/test/SemaCXX/static-assert.cpp

Index: clang/test/SemaCXX/static-assert.cpp
===
--- clang/test/SemaCXX/static-assert.cpp
+++ clang/test/SemaCXX/static-assert.cpp
@@ -29,13 +29,19 @@
 S s1; // expected-note {{in instantiation of template class 'S' requested here}}
 S s2;
 
-static_assert(false, L"\x"); // expected-error {{an unevaluated string literal cannot have an encoding prefix}} \
- // expected-error {{invalid escape sequence '\x' in an unevaluated string literal}}
-static_assert(false, u"\U000317FF"); // expected-error {{an unevaluated string literal cannot have an encoding prefix}}
-// FIXME: render this as u8"\u03A9"
-static_assert(false, u8"Ω"); // expected-error {{an unevaluated string literal cannot have an encoding prefix}}
-static_assert(false, L"\u1234"); // expected-error {{an unevaluated string literal cannot have an encoding prefix}}
-static_assert(false, L"\x1ff"// expected-error {{an unevaluated string literal cannot have an encoding prefix}} \
+static_assert(false, L"\x"); // expected-warning {{encoding prefix 'L' on an unevaluated string literal has no effect and is incompatible with c++2c}} \
+ // expected-error {{invalid escape sequence '\x' in an unevaluated string literal}} \
+ // expected-error {{hex escape sequence out of range}}
+static_assert(false, u"\U000317FF"); // expected-warning {{encoding prefix 'u' on an unevaluated string literal has no effect and is incompatible with c++2c}} \
+ // expected-error {{static assertion failed}}
+
+static_assert(false, u8"Ω"); // expected-warning {{encoding prefix 'u8' on an unevaluated string literal has no effect and is incompatible with c++2c}} \
+ // expected-error {{static assertion failed: Ω}}
+static_assert(false, L"\u1234"); // expected-warning {{encoding prefix 'L' on an unevaluated string literal has no effect and is incompatible with c++2c}} \
+ // expected-error {{static assertion failed: ሴ}}
+
+static_assert(false, L"\x1ff"// expected-warning {{encoding prefix 'L' on an unevaluated string literal has no effect and is incompatible with c++2c}} \
+ // expected-error {{hex escape sequence out of range}} \
  // expected-error {{invalid escape sequence '\x1ff' in an unevaluated string literal}}
  "0\x123"// expected-error {{invalid escape sequence '\x123' in an unevaluated string literal}}
  "fx\xf" // expected-error {{invalid escape sequence '\xf' in an unevaluated string literal}}
Index: clang/test/Sema/static-assert.c
===
--- clang/test/Sema/static-assert.c
+++ clang/test/Sema/static-assert.c
@@ -94,3 +94,20 @@
 // __builtin_strlen(literal) is considered an integer constant expression
 // and doesn't cause a pedantic warning
 #endif
+
+
+_Static_assert(0, L"\x"); // expected-warning {{encoding prefix 'L' on an unevaluated string literal has no effect}} \
+  // expected-error {{invalid escape sequence '\x' in an unevaluated string literal}} \
+  // expected-error {{hex escape sequence out of range}} \
+  // ext-warning {{'_Static_assert' is a C11 extension}}
+_Static_assert(0, L"\u1234"); // expected-warning {{encoding prefix 'L' on an unevaluated string literal has no effect}} \
+  // expected-error {{static assertion failed: ሴ}} \
+  // ext-warning {{'_Static_assert' is a C11 extension}}
+
+_Static_assert(0, L"\x1ff"  // expected-warning {{encoding prefix 'L' on an unevaluated string literal has no effect}} \
+// expected-error {{hex escape sequence out of range}} \
+// expected-error {{invalid escape sequence '\x1ff' in an unevaluated string literal}} \
+// ext-warning {{'_Static_assert' is a C11 extension}}
+   "0\x123" // expected-error {{invalid escape sequence '\x123' in an unevaluated string literal}}
+   "fx\xf"  // expected-error {{invalid escape 

[PATCH] D156596: [Clang] Produce a warning instead of an error in unevaluated strings before C++26

2023-08-04 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added a comment.

In D156596#4558097 , @cor3ntin wrote:

> Note: we are waiting for feedback from @hubert.reinterpretcast's people 
> before progressing this.

The "full" build hit some (unrelated) snags, but the initial results look good. 
The patch is awaiting C test cases.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D156596/new/

https://reviews.llvm.org/D156596

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D156596: [Clang] Produce a warning instead of an error in unevaluated strings before C++26

2023-08-03 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added a comment.

Note: we are waiting for feedback from @hubert.reinterpretcast's people before 
progressing this.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D156596/new/

https://reviews.llvm.org/D156596

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D156596: [Clang] Produce a warning instead of an error in unevaluated strings before C++26

2023-08-02 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticLexKinds.td:290
+  "encoding prefix '%0' on an unevaluated string literal has no effect"
+  "%select{| and is incompatible with c++2c}1">,
+  InGroup>;

cor3ntin wrote:
> hubert.reinterpretcast wrote:
> > aaron.ballman wrote:
> > > hubert.reinterpretcast wrote:
> > > > I am not seeing any tests covering C mode.
> > > > 
> > > > @aaron.ballman, can you confirm that you are okay with the warning when 
> > > > processing C code (and, moreover, the newly-added errors for numeric 
> > > > escape sequences)?
> > > > 
> > > Good call on C test coverage, thank you for bringing that up!
> > > 
> > > I think the behavior in C is reasonable, even if it's not mandated by the 
> > > standard. We're going from issuing an error in C to issuing a warning and 
> > > the warning text helpfully omits the C++2c part of the diagnostic, so it 
> > > seems like we're more relaxed in C than we previously were.
> > > 
> > > Do you have concerns about the behavior in C? (Or are you saying you'd 
> > > prefer this to be an error in C as it was before?)
> > My question was with respect to the change from the Clang 16 status quo for 
> > numeric escapes introduced by the prior change and carried forward with 
> > this one: https://godbolt.org/z/aneGr1Yfb
> > 
> > ```
> > _Static_assert(1, "\x30"); // error in Clang 17
> > ```
> > 
> Yes, this is intended, numeric escape sequences in unevaluated string 
> literals are not allowed in any language modes - the motivation for C is the 
> same as C++. 
Barring evidence that we're breaking working code without workarounds, I'm 
happy with the behavior in C. I don't think numeric escape sequences make a lot 
of sense in the contexts where these strings appear in C, same as for C++. 
However, if we had evidence that this breaks working code in problematic ways, 
we could consider changing it to warning-defaults-to-error.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D156596/new/

https://reviews.llvm.org/D156596

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D156596: [Clang] Produce a warning instead of an error in unevaluated strings before C++26

2023-08-01 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticLexKinds.td:290
+  "encoding prefix '%0' on an unevaluated string literal has no effect"
+  "%select{| and is incompatible with c++2c}1">,
+  InGroup>;

hubert.reinterpretcast wrote:
> aaron.ballman wrote:
> > hubert.reinterpretcast wrote:
> > > I am not seeing any tests covering C mode.
> > > 
> > > @aaron.ballman, can you confirm that you are okay with the warning when 
> > > processing C code (and, moreover, the newly-added errors for numeric 
> > > escape sequences)?
> > > 
> > Good call on C test coverage, thank you for bringing that up!
> > 
> > I think the behavior in C is reasonable, even if it's not mandated by the 
> > standard. We're going from issuing an error in C to issuing a warning and 
> > the warning text helpfully omits the C++2c part of the diagnostic, so it 
> > seems like we're more relaxed in C than we previously were.
> > 
> > Do you have concerns about the behavior in C? (Or are you saying you'd 
> > prefer this to be an error in C as it was before?)
> My question was with respect to the change from the Clang 16 status quo for 
> numeric escapes introduced by the prior change and carried forward with this 
> one: https://godbolt.org/z/aneGr1Yfb
> 
> ```
> _Static_assert(1, "\x30"); // error in Clang 17
> ```
> 
Yes, this is intended, numeric escape sequences in unevaluated string literals 
are not allowed in any language modes - the motivation for C is the same as 
C++. 


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D156596/new/

https://reviews.llvm.org/D156596

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D156596: [Clang] Produce a warning instead of an error in unevaluated strings before C++26

2023-08-01 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticLexKinds.td:290
+  "encoding prefix '%0' on an unevaluated string literal has no effect"
+  "%select{| and is incompatible with c++2c}1">,
+  InGroup>;

aaron.ballman wrote:
> hubert.reinterpretcast wrote:
> > I am not seeing any tests covering C mode.
> > 
> > @aaron.ballman, can you confirm that you are okay with the warning when 
> > processing C code (and, moreover, the newly-added errors for numeric escape 
> > sequences)?
> > 
> Good call on C test coverage, thank you for bringing that up!
> 
> I think the behavior in C is reasonable, even if it's not mandated by the 
> standard. We're going from issuing an error in C to issuing a warning and the 
> warning text helpfully omits the C++2c part of the diagnostic, so it seems 
> like we're more relaxed in C than we previously were.
> 
> Do you have concerns about the behavior in C? (Or are you saying you'd prefer 
> this to be an error in C as it was before?)
My question was with respect to the change from the Clang 16 status quo for 
numeric escapes introduced by the prior change and carried forward with this 
one: https://godbolt.org/z/aneGr1Yfb

```
_Static_assert(1, "\x30"); // error in Clang 17
```



Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D156596/new/

https://reviews.llvm.org/D156596

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D156596: [Clang] Produce a warning instead of an error in unevaluated strings before C++26

2023-08-01 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticLexKinds.td:290
+  "encoding prefix '%0' on an unevaluated string literal has no effect"
+  "%select{| and is incompatible with c++2c}1">,
+  InGroup>;

hubert.reinterpretcast wrote:
> I am not seeing any tests covering C mode.
> 
> @aaron.ballman, can you confirm that you are okay with the warning when 
> processing C code (and, moreover, the newly-added errors for numeric escape 
> sequences)?
> 
Good call on C test coverage, thank you for bringing that up!

I think the behavior in C is reasonable, even if it's not mandated by the 
standard. We're going from issuing an error in C to issuing a warning and the 
warning text helpfully omits the C++2c part of the diagnostic, so it seems like 
we're more relaxed in C than we previously were.

Do you have concerns about the behavior in C? (Or are you saying you'd prefer 
this to be an error in C as it was before?)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D156596/new/

https://reviews.llvm.org/D156596

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D156596: [Clang] Produce a warning instead of an error in unevaluated strings before C++26

2023-08-01 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticLexKinds.td:290
+  "encoding prefix '%0' on an unevaluated string literal has no effect"
+  "%select{| and is incompatible with c++2c}1">,
+  InGroup>;

I am not seeing any tests covering C mode.

@aaron.ballman, can you confirm that you are okay with the warning when 
processing C code (and, moreover, the newly-added errors for numeric escape 
sequences)?



Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D156596/new/

https://reviews.llvm.org/D156596

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D156596: [Clang] Produce a warning instead of an error in unevaluated strings before C++26

2023-08-01 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added a comment.

In D156596#4546742 , @aaron.ballman 
wrote:

> If so, I'd like @hubert.reinterpretcast to mention if this works for his 
> needs.

We are putting together a build for the (known) affected groups. I will report 
back when we have results.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D156596/new/

https://reviews.llvm.org/D156596

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D156596: [Clang] Produce a warning instead of an error in unevaluated strings before C++26

2023-08-01 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added inline comments.



Comment at: clang/test/CXX/dcl.dcl/dcl.link/p2.cpp:11-14
+extern u8"C" {}  // expected-warning {{encoding prefix 'u8' on an unevaluated 
string literal has no effect and is incompatible with c++2c}}
+extern L"C" {}   // expected-warning {{encoding prefix 'L' on an unevaluated 
string literal has no effect and is incompatible with c++2c}}
+extern u"C++" {} // expected-warning {{encoding prefix 'u' on an unevaluated 
string literal has no effect and is incompatible with c++2c}}
+extern U"C" {}   // expected-warning {{encoding prefix 'U' on an unevaluated 
string literal has no effect and is incompatible with c++2c}}

Note that was ill-formed in clang 16, despite being well-formed in the standard.



Comment at: clang/test/SemaCXX/static-assert.cpp:44-45
+static_assert(false, L"\x1ff"// expected-warning {{encoding prefix 'L' on 
an unevaluated string literal has no effect and is incompatible with c++2c}} \
+ // expected-error {{hex escape sequence out 
of range}} \
  // expected-error {{invalid escape sequence 
'\x1ff' in an unevaluated string literal}}
  "0\x123"// expected-error {{invalid escape sequence 
'\x123' in an unevaluated string literal}}

hubert.reinterpretcast wrote:
> I doubt that it is a problem, but Clang 16 accepted such hex escapes.
Yes, I only downgraded to a warning what you had reports about.
I haven't seen that pattern in the wild and i don't think anyone who would use 
that isn't confused on some level.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D156596/new/

https://reviews.llvm.org/D156596

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D156596: [Clang] Produce a warning instead of an error in unevaluated strings before C++26

2023-07-31 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added inline comments.



Comment at: clang/test/SemaCXX/static-assert.cpp:44-45
+static_assert(false, L"\x1ff"// expected-warning {{encoding prefix 'L' on 
an unevaluated string literal has no effect and is incompatible with c++2c}} \
+ // expected-error {{hex escape sequence out 
of range}} \
  // expected-error {{invalid escape sequence 
'\x1ff' in an unevaluated string literal}}
  "0\x123"// expected-error {{invalid escape sequence 
'\x123' in an unevaluated string literal}}

I doubt that it is a problem, but Clang 16 accepted such hex escapes.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D156596/new/

https://reviews.llvm.org/D156596

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D156596: [Clang] Produce a warning instead of an error in unevaluated strings before C++26

2023-07-31 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D156596#4546787 , @cor3ntin wrote:

> Oups, sorry, the context is this PR https://reviews.llvm.org/D105759#4543246

I kind of figured. :-) But we want the context in the patch summary since 
that's what typically makes it to the commit message, and we don't want folks 
doing code archeology to have to click through to figure that context out.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D156596/new/

https://reviews.llvm.org/D156596

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D156596: [Clang] Produce a warning instead of an error in unevaluated strings before C++26

2023-07-31 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added a comment.

Oups, sorry, the context is this PR https://reviews.llvm.org/D105759#4543246


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D156596/new/

https://reviews.llvm.org/D156596

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D156596: [Clang] Produce a warning instead of an error in unevaluated strings before C++26

2023-07-31 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a subscriber: hubert.reinterpretcast.
aaron.ballman added a comment.

Please add more details to the patch summary explaining why you're making these 
changes. Also, I assume this is to be backported to Clang 17? If so, I'd like 
@hubert.reinterpretcast to mention if this works for his needs.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D156596/new/

https://reviews.llvm.org/D156596

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D156596: [Clang] Produce a warning instead of an error in unevaluated strings before C++26

2023-07-29 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 545374.
cor3ntin added a comment.

Format + Add FixIt tests


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D156596/new/

https://reviews.llvm.org/D156596

Files:
  clang/include/clang/Basic/DiagnosticLexKinds.td
  clang/lib/Lex/LiteralSupport.cpp
  clang/test/CXX/dcl.dcl/dcl.link/p2.cpp
  clang/test/CXX/dcl.dcl/p4-0x.cpp
  clang/test/FixIt/unevaluated-strings.cpp
  clang/test/SemaCXX/static-assert.cpp

Index: clang/test/SemaCXX/static-assert.cpp
===
--- clang/test/SemaCXX/static-assert.cpp
+++ clang/test/SemaCXX/static-assert.cpp
@@ -29,13 +29,19 @@
 S s1; // expected-note {{in instantiation of template class 'S' requested here}}
 S s2;
 
-static_assert(false, L"\x"); // expected-error {{an unevaluated string literal cannot have an encoding prefix}} \
- // expected-error {{invalid escape sequence '\x' in an unevaluated string literal}}
-static_assert(false, u"\U000317FF"); // expected-error {{an unevaluated string literal cannot have an encoding prefix}}
-// FIXME: render this as u8"\u03A9"
-static_assert(false, u8"Ω"); // expected-error {{an unevaluated string literal cannot have an encoding prefix}}
-static_assert(false, L"\u1234"); // expected-error {{an unevaluated string literal cannot have an encoding prefix}}
-static_assert(false, L"\x1ff"// expected-error {{an unevaluated string literal cannot have an encoding prefix}} \
+static_assert(false, L"\x"); // expected-warning {{encoding prefix 'L' on an unevaluated string literal has no effect and is incompatible with c++2c}} \
+ // expected-error {{invalid escape sequence '\x' in an unevaluated string literal}} \
+ // expected-error {{hex escape sequence out of range}}
+static_assert(false, u"\U000317FF"); // expected-warning {{encoding prefix 'u' on an unevaluated string literal has no effect and is incompatible with c++2c}} \
+ // expected-error {{static assertion failed}}
+
+static_assert(false, u8"Ω"); // expected-warning {{encoding prefix 'u8' on an unevaluated string literal has no effect and is incompatible with c++2c}} \
+ // expected-error {{static assertion failed: Ω}}
+static_assert(false, L"\u1234"); // expected-warning {{encoding prefix 'L' on an unevaluated string literal has no effect and is incompatible with c++2c}} \
+ // expected-error {{static assertion failed: ሴ}}
+
+static_assert(false, L"\x1ff"// expected-warning {{encoding prefix 'L' on an unevaluated string literal has no effect and is incompatible with c++2c}} \
+ // expected-error {{hex escape sequence out of range}} \
  // expected-error {{invalid escape sequence '\x1ff' in an unevaluated string literal}}
  "0\x123"// expected-error {{invalid escape sequence '\x123' in an unevaluated string literal}}
  "fx\xf" // expected-error {{invalid escape sequence '\xf' in an unevaluated string literal}}
Index: clang/test/FixIt/unevaluated-strings.cpp
===
--- /dev/null
+++ clang/test/FixIt/unevaluated-strings.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -verify -std=c++2c %s
+// RUN: cp %s %t
+// RUN: not %clang_cc1 -x c++ -std=c++2c -fixit %t
+// RUN: %clang_cc1 -x c++ -std=c++2c %t
+// RUN: not %clang_cc1 -std=c++2c -x c++ -fsyntax-only -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
+
+static_assert(true, L""); // expected-error{{an unevaluated string literal cannot have an encoding prefix}}
+// CHECK: fix-it:{{.*}}:{7:21-7:22}
+
+static_assert(true, u8""); // expected-error{{an unevaluated string literal cannot have an encoding prefix}}
+// CHECK: fix-it:{{.*}}:{10:21-10:23}
+
+static_assert(true, u""); // expected-error{{an unevaluated string literal cannot have an encoding prefix}}
+// CHECK: fix-it:{{.*}}:{13:21-13:22}
+
+static_assert(true, U""); // expected-error{{an unevaluated string literal cannot have an encoding prefix}}
+// CHECK: fix-it:{{.*}}:{16:21-16:22}
Index: clang/test/CXX/dcl.dcl/p4-0x.cpp
===
--- clang/test/CXX/dcl.dcl/p4-0x.cpp
+++ clang/test/CXX/dcl.dcl/p4-0x.cpp
@@ -18,7 +18,7 @@
 static_assert(T(), "");
 static_assert(U(), ""); // expected-error {{ambiguous}}
 
-static_assert(false, L"\x14hi" // expected-error {{an unevaluated string literal cannot have an encoding prefix}} \
+static_assert(false, L"\x14hi" // expected-warning {{encoding prefix 'L' on an unevaluated string literal has no effect and is incompatible with c++2c}} \
// expected-error {{invalid escape sequence '\x14' in 

[PATCH] D156596: [Clang] Produce a warning instead of an error in unevaluated strings before C++26

2023-07-29 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin created this revision.
Herald added a project: All.
cor3ntin requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D156596

Files:
  clang/include/clang/Basic/DiagnosticLexKinds.td
  clang/lib/Lex/LiteralSupport.cpp
  clang/test/CXX/dcl.dcl/dcl.link/p2.cpp
  clang/test/CXX/dcl.dcl/p4-0x.cpp
  clang/test/SemaCXX/static-assert.cpp

Index: clang/test/SemaCXX/static-assert.cpp
===
--- clang/test/SemaCXX/static-assert.cpp
+++ clang/test/SemaCXX/static-assert.cpp
@@ -29,13 +29,19 @@
 S s1; // expected-note {{in instantiation of template class 'S' requested here}}
 S s2;
 
-static_assert(false, L"\x"); // expected-error {{an unevaluated string literal cannot have an encoding prefix}} \
- // expected-error {{invalid escape sequence '\x' in an unevaluated string literal}}
-static_assert(false, u"\U000317FF"); // expected-error {{an unevaluated string literal cannot have an encoding prefix}}
-// FIXME: render this as u8"\u03A9"
-static_assert(false, u8"Ω"); // expected-error {{an unevaluated string literal cannot have an encoding prefix}}
-static_assert(false, L"\u1234"); // expected-error {{an unevaluated string literal cannot have an encoding prefix}}
-static_assert(false, L"\x1ff"// expected-error {{an unevaluated string literal cannot have an encoding prefix}} \
+static_assert(false, L"\x"); // expected-warning {{encoding prefix 'L' on an unevaluated string literal has no effect and is incompatible with c++2c}} \
+ // expected-error {{invalid escape sequence '\x' in an unevaluated string literal}} \
+ // expected-error {{hex escape sequence out of range}}
+static_assert(false, u"\U000317FF"); // expected-warning {{encoding prefix 'u' on an unevaluated string literal has no effect and is incompatible with c++2c}} \
+ // expected-error {{static assertion failed}}
+
+static_assert(false, u8"Ω"); // expected-warning {{encoding prefix 'u8' on an unevaluated string literal has no effect and is incompatible with c++2c}} \
+ // expected-error {{static assertion failed: Ω}}
+static_assert(false, L"\u1234"); // expected-warning {{encoding prefix 'L' on an unevaluated string literal has no effect and is incompatible with c++2c}} \
+ // expected-error {{static assertion failed: ሴ}}
+
+static_assert(false, L"\x1ff"// expected-warning {{encoding prefix 'L' on an unevaluated string literal has no effect and is incompatible with c++2c}} \
+ // expected-error {{hex escape sequence out of range}} \
  // expected-error {{invalid escape sequence '\x1ff' in an unevaluated string literal}}
  "0\x123"// expected-error {{invalid escape sequence '\x123' in an unevaluated string literal}}
  "fx\xf" // expected-error {{invalid escape sequence '\xf' in an unevaluated string literal}}
Index: clang/test/CXX/dcl.dcl/p4-0x.cpp
===
--- clang/test/CXX/dcl.dcl/p4-0x.cpp
+++ clang/test/CXX/dcl.dcl/p4-0x.cpp
@@ -18,7 +18,7 @@
 static_assert(T(), "");
 static_assert(U(), ""); // expected-error {{ambiguous}}
 
-static_assert(false, L"\x14hi" // expected-error {{an unevaluated string literal cannot have an encoding prefix}} \
+static_assert(false, L"\x14hi" // expected-warning {{encoding prefix 'L' on an unevaluated string literal has no effect and is incompatible with c++2c}} \
// expected-error {{invalid escape sequence '\x14' in an unevaluated string literal}}
  "!"
  R"x(")x");
Index: clang/test/CXX/dcl.dcl/dcl.link/p2.cpp
===
--- clang/test/CXX/dcl.dcl/dcl.link/p2.cpp
+++ clang/test/CXX/dcl.dcl/dcl.link/p2.cpp
@@ -8,7 +8,7 @@
 extern "C" plusplus {
 }
 
-extern u8"C" {}  // expected-error {{an unevaluated string literal cannot have an encoding prefix}}
-extern L"C" {}   // expected-error {{an unevaluated string literal cannot have an encoding prefix}}
-extern u"C++" {} // expected-error {{an unevaluated string literal cannot have an encoding prefix}}
-extern U"C" {}   // expected-error {{an unevaluated string literal cannot have an encoding prefix}}
+extern u8"C" {}  // expected-warning {{encoding prefix 'u8' on an unevaluated string literal has no effect and is incompatible with c++2c}}
+extern L"C" {}   // expected-warning {{encoding prefix 'L' on an unevaluated string literal has no effect and is incompatible with c++2c}}
+extern u"C++" {} // expected-warning {{encoding prefix 'u' on an