[clang] [clang] Support `__is_trivially_copyable(int()&)==false` (PR #81298)

2024-03-29 Thread Amirreza Ashouri via cfe-commits

AMP999 wrote:

I don't know, but it seems to me that ideally the `DSC` here would be 
`DSC_template_type_arg`, not just `DSC_template_arg`. Is there a way to make 
that happen?

https://github.com/llvm/llvm-project/pull/81298
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Support `__is_trivially_copyable(int()&)==false` (PR #81298)

2024-03-28 Thread via cfe-commits

fahadnayyar wrote:

Filed this issue: https://github.com/llvm/llvm-project/issues/86997 

https://github.com/llvm/llvm-project/pull/81298
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Support `__is_trivially_copyable(int()&)==false` (PR #81298)

2024-03-28 Thread via cfe-commits

fahadnayyar wrote:

@AaronBallman precisely!
`DSC` now is : `DSC_template_arg`
`DSC` in earlier clang was : `DSC_type_specifier`

@AMP999 do you have thoughts about how we can fix this issue?

https://github.com/llvm/llvm-project/pull/81298
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Support `__is_trivially_copyable(int()&)==false` (PR #81298)

2024-03-28 Thread Aaron Ballman via cfe-commits

AaronBallman wrote:

I think the former diagnostic is more clear. It seems the issue is around here: 
https://github.com/llvm/llvm-project/blob/d7975c9d93fb4a69c0bd79d7d5b3f6be77a25c73/clang/lib/Parse/ParseDecl.cpp#L2828

We changed the `DeclSpecContext` so we hit the `else if` rather than the `if` 
because of `isTypeSpecifier()`.

https://github.com/llvm/llvm-project/pull/81298
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Support `__is_trivially_copyable(int()&)==false` (PR #81298)

2024-03-27 Thread via cfe-commits

fahadnayyar wrote:

Hey folks,

Because of this change the error message for certain type traits changed.
For example:
```
void f(void) {
  __has_nothrow_copy();
}
```
Earlier the error message was:  `expected a type`
New error message is: `type name requires a specifier or qualifier`

Ref: https://godbolt.org/z/d4884bYz3

I personally feel the previous error made more sense for this case as the type 
name is missing in the type trait call. If the type name  is present but the 
qualifier or specifier are not present then only the new message makes sense.

What do you think, is it a regression or correct behaviour?
@AMP999 @cor3ntin @AaronBallman 

https://github.com/llvm/llvm-project/pull/81298
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Support `__is_trivially_copyable(int()&)==false` (PR #81298)

2024-03-05 Thread via cfe-commits

https://github.com/cor3ntin closed 
https://github.com/llvm/llvm-project/pull/81298
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Support `__is_trivially_copyable(int()&)==false` (PR #81298)

2024-03-04 Thread via cfe-commits

https://github.com/cor3ntin approved this pull request.

LGTM

https://github.com/llvm/llvm-project/pull/81298
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Support `__is_trivially_copyable(int()&)==false` (PR #81298)

2024-03-04 Thread Amirreza Ashouri via cfe-commits

AMP999 wrote:

@cor3ntin I've reflected your suggestions in the code. Could you help me to 
land this PR, if you it looks good to you?

https://github.com/llvm/llvm-project/pull/81298
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Support `__is_trivially_copyable(int()&)==false` (PR #81298)

2024-03-04 Thread Amirreza Ashouri via cfe-commits

https://github.com/AMP999 updated 
https://github.com/llvm/llvm-project/pull/81298

>From d59c262b31937fdd2b907ec11d7f08e4a385007c Mon Sep 17 00:00:00 2001
From: Amirreza Ashouri 
Date: Fri, 9 Feb 2024 21:55:03 +0330
Subject: [PATCH 1/8] [clang] Support `__is_trivially_copyable(int()&)==false`

IMHO it would be productive to make a similar change for `typeid`,
in `ParseCXXTypeid`, in order to improve Clang's error message for
https://godbolt.org/z/oKKWxeYra
But that might be better done by adding a new DeclaratorContext
specifically for TypeidArg, instead of pretending that the argument
to `typeid` is a template argument, because I don't know what else
that change might affect.

Fixes https://github.com/llvm/llvm-project/issues/77585
---
 clang/lib/Parse/ParseExprCXX.cpp | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/clang/lib/Parse/ParseExprCXX.cpp b/clang/lib/Parse/ParseExprCXX.cpp
index fd262ff31e661a..746a8b2286ac4c 100644
--- a/clang/lib/Parse/ParseExprCXX.cpp
+++ b/clang/lib/Parse/ParseExprCXX.cpp
@@ -3899,7 +3899,9 @@ ExprResult Parser::ParseTypeTrait() {
   SmallVector Args;
   do {
 // Parse the next type.
-TypeResult Ty = ParseTypeName();
+TypeResult Ty = ParseTypeName(nullptr, getLangOpts().CPlusPlus
+   ? DeclaratorContext::TemplateArg
+   : DeclaratorContext::TypeName);
 if (Ty.isInvalid()) {
   Parens.skipToEnd();
   return ExprError();
@@ -3941,7 +3943,7 @@ ExprResult Parser::ParseArrayTypeTrait() {
   if (T.expectAndConsume())
 return ExprError();
 
-  TypeResult Ty = ParseTypeName();
+  TypeResult Ty = ParseTypeName(nullptr, DeclaratorContext::TemplateArg);
   if (Ty.isInvalid()) {
 SkipUntil(tok::comma, StopAtSemi);
 SkipUntil(tok::r_paren, StopAtSemi);

>From 4c58f4f351a17cf4bf3c9d0ccfa118d0fe3a52de Mon Sep 17 00:00:00 2001
From: Amirreza Ashouri 
Date: Sun, 11 Feb 2024 20:35:04 +0330
Subject: [PATCH 2/8] [clang] Fix the failing test in #81298

---
 clang/test/Sema/static-assert.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/test/Sema/static-assert.c b/clang/test/Sema/static-assert.c
index 4e9e6b7ee558bd..7e1ce135cbd995 100644
--- a/clang/test/Sema/static-assert.c
+++ b/clang/test/Sema/static-assert.c
@@ -57,7 +57,7 @@ UNION(char[2], short) u2 = { .one = { 'a', 'b' } }; // 
ext-warning 3 {{'_Static_
 typedef UNION(char, short) U3; // expected-error {{static assertion failed due 
to requirement 'sizeof(char) == sizeof(short)': type size mismatch}} \
// expected-note{{evaluates to '1 == 2'}} \
// ext-warning 3 {{'_Static_assert' is a C11 
extension}}
-typedef UNION(float, 0.5f) U4; // expected-error {{expected a type}} \
+typedef UNION(float, 0.5f) U4; // expected-error-re type name requires a 
specifier or qualifier|expected a type \
// ext-warning 3 {{'_Static_assert' is a C11 
extension}}
 
 // After defining the assert macro in MS-compatibility mode, we should

>From 03c2cfb73fc291ecfc5318077b295a6e38cd9869 Mon Sep 17 00:00:00 2001
From: Amirreza Ashouri 
Date: Mon, 12 Feb 2024 23:47:33 +0330
Subject: [PATCH 3/8] Add a release note.

---
 clang/docs/ReleaseNotes.rst | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 32440ee64e3ebe..0beb10af709804 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -217,6 +217,8 @@ Bug Fixes to C++ Support
   Fixes (`#80971 ICE when explicit object parameter be a function parameter 
pack`)
 - Fixed a bug where abbreviated function templates would append their invented 
template parameters to
   an empty template parameter lists.
+- Fix parsing of abominable function types inside type traits. 
+  Fixes (`#77585 `_)
 
 Bug Fixes to AST Handling
 ^

>From 0de0aa09fb5f45fcde688d988377582b9257b6b8 Mon Sep 17 00:00:00 2001
From: Amirreza Ashouri 
Date: Tue, 13 Feb 2024 01:19:27 +0330
Subject: [PATCH 4/8] Remove trailing white space in ReleaseNotes.rst.

---
 clang/docs/ReleaseNotes.rst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 0beb10af709804..55f3faea365a07 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -217,7 +217,7 @@ Bug Fixes to C++ Support
   Fixes (`#80971 ICE when explicit object parameter be a function parameter 
pack`)
 - Fixed a bug where abbreviated function templates would append their invented 
template parameters to
   an empty template parameter lists.
-- Fix parsing of abominable function types inside type traits. 
+- Fix parsing of abominable function types inside type traits.
   Fixes (`#77585 `_)
 
 Bug Fixes to AST Handling

>

[clang] [clang] Support `__is_trivially_copyable(int()&)==false` (PR #81298)

2024-03-04 Thread Amirreza Ashouri via cfe-commits

https://github.com/AMP999 updated 
https://github.com/llvm/llvm-project/pull/81298

>From d59c262b31937fdd2b907ec11d7f08e4a385007c Mon Sep 17 00:00:00 2001
From: Amirreza Ashouri 
Date: Fri, 9 Feb 2024 21:55:03 +0330
Subject: [PATCH 1/7] [clang] Support `__is_trivially_copyable(int()&)==false`

IMHO it would be productive to make a similar change for `typeid`,
in `ParseCXXTypeid`, in order to improve Clang's error message for
https://godbolt.org/z/oKKWxeYra
But that might be better done by adding a new DeclaratorContext
specifically for TypeidArg, instead of pretending that the argument
to `typeid` is a template argument, because I don't know what else
that change might affect.

Fixes https://github.com/llvm/llvm-project/issues/77585
---
 clang/lib/Parse/ParseExprCXX.cpp | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/clang/lib/Parse/ParseExprCXX.cpp b/clang/lib/Parse/ParseExprCXX.cpp
index fd262ff31e661a..746a8b2286ac4c 100644
--- a/clang/lib/Parse/ParseExprCXX.cpp
+++ b/clang/lib/Parse/ParseExprCXX.cpp
@@ -3899,7 +3899,9 @@ ExprResult Parser::ParseTypeTrait() {
   SmallVector Args;
   do {
 // Parse the next type.
-TypeResult Ty = ParseTypeName();
+TypeResult Ty = ParseTypeName(nullptr, getLangOpts().CPlusPlus
+   ? DeclaratorContext::TemplateArg
+   : DeclaratorContext::TypeName);
 if (Ty.isInvalid()) {
   Parens.skipToEnd();
   return ExprError();
@@ -3941,7 +3943,7 @@ ExprResult Parser::ParseArrayTypeTrait() {
   if (T.expectAndConsume())
 return ExprError();
 
-  TypeResult Ty = ParseTypeName();
+  TypeResult Ty = ParseTypeName(nullptr, DeclaratorContext::TemplateArg);
   if (Ty.isInvalid()) {
 SkipUntil(tok::comma, StopAtSemi);
 SkipUntil(tok::r_paren, StopAtSemi);

>From 4c58f4f351a17cf4bf3c9d0ccfa118d0fe3a52de Mon Sep 17 00:00:00 2001
From: Amirreza Ashouri 
Date: Sun, 11 Feb 2024 20:35:04 +0330
Subject: [PATCH 2/7] [clang] Fix the failing test in #81298

---
 clang/test/Sema/static-assert.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/test/Sema/static-assert.c b/clang/test/Sema/static-assert.c
index 4e9e6b7ee558bd..7e1ce135cbd995 100644
--- a/clang/test/Sema/static-assert.c
+++ b/clang/test/Sema/static-assert.c
@@ -57,7 +57,7 @@ UNION(char[2], short) u2 = { .one = { 'a', 'b' } }; // 
ext-warning 3 {{'_Static_
 typedef UNION(char, short) U3; // expected-error {{static assertion failed due 
to requirement 'sizeof(char) == sizeof(short)': type size mismatch}} \
// expected-note{{evaluates to '1 == 2'}} \
// ext-warning 3 {{'_Static_assert' is a C11 
extension}}
-typedef UNION(float, 0.5f) U4; // expected-error {{expected a type}} \
+typedef UNION(float, 0.5f) U4; // expected-error-re type name requires a 
specifier or qualifier|expected a type \
// ext-warning 3 {{'_Static_assert' is a C11 
extension}}
 
 // After defining the assert macro in MS-compatibility mode, we should

>From 03c2cfb73fc291ecfc5318077b295a6e38cd9869 Mon Sep 17 00:00:00 2001
From: Amirreza Ashouri 
Date: Mon, 12 Feb 2024 23:47:33 +0330
Subject: [PATCH 3/7] Add a release note.

---
 clang/docs/ReleaseNotes.rst | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 32440ee64e3ebe..0beb10af709804 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -217,6 +217,8 @@ Bug Fixes to C++ Support
   Fixes (`#80971 ICE when explicit object parameter be a function parameter 
pack`)
 - Fixed a bug where abbreviated function templates would append their invented 
template parameters to
   an empty template parameter lists.
+- Fix parsing of abominable function types inside type traits. 
+  Fixes (`#77585 `_)
 
 Bug Fixes to AST Handling
 ^

>From 0de0aa09fb5f45fcde688d988377582b9257b6b8 Mon Sep 17 00:00:00 2001
From: Amirreza Ashouri 
Date: Tue, 13 Feb 2024 01:19:27 +0330
Subject: [PATCH 4/7] Remove trailing white space in ReleaseNotes.rst.

---
 clang/docs/ReleaseNotes.rst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 0beb10af709804..55f3faea365a07 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -217,7 +217,7 @@ Bug Fixes to C++ Support
   Fixes (`#80971 ICE when explicit object parameter be a function parameter 
pack`)
 - Fixed a bug where abbreviated function templates would append their invented 
template parameters to
   an empty template parameter lists.
-- Fix parsing of abominable function types inside type traits. 
+- Fix parsing of abominable function types inside type traits.
   Fixes (`#77585 `_)
 
 Bug Fixes to AST Handling

>

[clang] [clang] Support `__is_trivially_copyable(int()&)==false` (PR #81298)

2024-03-04 Thread Amirreza Ashouri via cfe-commits

https://github.com/AMP999 updated 
https://github.com/llvm/llvm-project/pull/81298

>From d59c262b31937fdd2b907ec11d7f08e4a385007c Mon Sep 17 00:00:00 2001
From: Amirreza Ashouri 
Date: Fri, 9 Feb 2024 21:55:03 +0330
Subject: [PATCH 1/6] [clang] Support `__is_trivially_copyable(int()&)==false`

IMHO it would be productive to make a similar change for `typeid`,
in `ParseCXXTypeid`, in order to improve Clang's error message for
https://godbolt.org/z/oKKWxeYra
But that might be better done by adding a new DeclaratorContext
specifically for TypeidArg, instead of pretending that the argument
to `typeid` is a template argument, because I don't know what else
that change might affect.

Fixes https://github.com/llvm/llvm-project/issues/77585
---
 clang/lib/Parse/ParseExprCXX.cpp | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/clang/lib/Parse/ParseExprCXX.cpp b/clang/lib/Parse/ParseExprCXX.cpp
index fd262ff31e661a..746a8b2286ac4c 100644
--- a/clang/lib/Parse/ParseExprCXX.cpp
+++ b/clang/lib/Parse/ParseExprCXX.cpp
@@ -3899,7 +3899,9 @@ ExprResult Parser::ParseTypeTrait() {
   SmallVector Args;
   do {
 // Parse the next type.
-TypeResult Ty = ParseTypeName();
+TypeResult Ty = ParseTypeName(nullptr, getLangOpts().CPlusPlus
+   ? DeclaratorContext::TemplateArg
+   : DeclaratorContext::TypeName);
 if (Ty.isInvalid()) {
   Parens.skipToEnd();
   return ExprError();
@@ -3941,7 +3943,7 @@ ExprResult Parser::ParseArrayTypeTrait() {
   if (T.expectAndConsume())
 return ExprError();
 
-  TypeResult Ty = ParseTypeName();
+  TypeResult Ty = ParseTypeName(nullptr, DeclaratorContext::TemplateArg);
   if (Ty.isInvalid()) {
 SkipUntil(tok::comma, StopAtSemi);
 SkipUntil(tok::r_paren, StopAtSemi);

>From 4c58f4f351a17cf4bf3c9d0ccfa118d0fe3a52de Mon Sep 17 00:00:00 2001
From: Amirreza Ashouri 
Date: Sun, 11 Feb 2024 20:35:04 +0330
Subject: [PATCH 2/6] [clang] Fix the failing test in #81298

---
 clang/test/Sema/static-assert.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/test/Sema/static-assert.c b/clang/test/Sema/static-assert.c
index 4e9e6b7ee558bd..7e1ce135cbd995 100644
--- a/clang/test/Sema/static-assert.c
+++ b/clang/test/Sema/static-assert.c
@@ -57,7 +57,7 @@ UNION(char[2], short) u2 = { .one = { 'a', 'b' } }; // 
ext-warning 3 {{'_Static_
 typedef UNION(char, short) U3; // expected-error {{static assertion failed due 
to requirement 'sizeof(char) == sizeof(short)': type size mismatch}} \
// expected-note{{evaluates to '1 == 2'}} \
// ext-warning 3 {{'_Static_assert' is a C11 
extension}}
-typedef UNION(float, 0.5f) U4; // expected-error {{expected a type}} \
+typedef UNION(float, 0.5f) U4; // expected-error-re type name requires a 
specifier or qualifier|expected a type \
// ext-warning 3 {{'_Static_assert' is a C11 
extension}}
 
 // After defining the assert macro in MS-compatibility mode, we should

>From 03c2cfb73fc291ecfc5318077b295a6e38cd9869 Mon Sep 17 00:00:00 2001
From: Amirreza Ashouri 
Date: Mon, 12 Feb 2024 23:47:33 +0330
Subject: [PATCH 3/6] Add a release note.

---
 clang/docs/ReleaseNotes.rst | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 32440ee64e3ebe..0beb10af709804 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -217,6 +217,8 @@ Bug Fixes to C++ Support
   Fixes (`#80971 ICE when explicit object parameter be a function parameter 
pack`)
 - Fixed a bug where abbreviated function templates would append their invented 
template parameters to
   an empty template parameter lists.
+- Fix parsing of abominable function types inside type traits. 
+  Fixes (`#77585 `_)
 
 Bug Fixes to AST Handling
 ^

>From 0de0aa09fb5f45fcde688d988377582b9257b6b8 Mon Sep 17 00:00:00 2001
From: Amirreza Ashouri 
Date: Tue, 13 Feb 2024 01:19:27 +0330
Subject: [PATCH 4/6] Remove trailing white space in ReleaseNotes.rst.

---
 clang/docs/ReleaseNotes.rst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 0beb10af709804..55f3faea365a07 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -217,7 +217,7 @@ Bug Fixes to C++ Support
   Fixes (`#80971 ICE when explicit object parameter be a function parameter 
pack`)
 - Fixed a bug where abbreviated function templates would append their invented 
template parameters to
   an empty template parameter lists.
-- Fix parsing of abominable function types inside type traits. 
+- Fix parsing of abominable function types inside type traits.
   Fixes (`#77585 `_)
 
 Bug Fixes to AST Handling

>

[clang] [clang] Support `__is_trivially_copyable(int()&)==false` (PR #81298)

2024-02-26 Thread Amirreza Ashouri via cfe-commits

https://github.com/AMP999 updated 
https://github.com/llvm/llvm-project/pull/81298

>From d59c262b31937fdd2b907ec11d7f08e4a385007c Mon Sep 17 00:00:00 2001
From: Amirreza Ashouri 
Date: Fri, 9 Feb 2024 21:55:03 +0330
Subject: [PATCH 1/5] [clang] Support `__is_trivially_copyable(int()&)==false`

IMHO it would be productive to make a similar change for `typeid`,
in `ParseCXXTypeid`, in order to improve Clang's error message for
https://godbolt.org/z/oKKWxeYra
But that might be better done by adding a new DeclaratorContext
specifically for TypeidArg, instead of pretending that the argument
to `typeid` is a template argument, because I don't know what else
that change might affect.

Fixes https://github.com/llvm/llvm-project/issues/77585
---
 clang/lib/Parse/ParseExprCXX.cpp | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/clang/lib/Parse/ParseExprCXX.cpp b/clang/lib/Parse/ParseExprCXX.cpp
index fd262ff31e661a..746a8b2286ac4c 100644
--- a/clang/lib/Parse/ParseExprCXX.cpp
+++ b/clang/lib/Parse/ParseExprCXX.cpp
@@ -3899,7 +3899,9 @@ ExprResult Parser::ParseTypeTrait() {
   SmallVector Args;
   do {
 // Parse the next type.
-TypeResult Ty = ParseTypeName();
+TypeResult Ty = ParseTypeName(nullptr, getLangOpts().CPlusPlus
+   ? DeclaratorContext::TemplateArg
+   : DeclaratorContext::TypeName);
 if (Ty.isInvalid()) {
   Parens.skipToEnd();
   return ExprError();
@@ -3941,7 +3943,7 @@ ExprResult Parser::ParseArrayTypeTrait() {
   if (T.expectAndConsume())
 return ExprError();
 
-  TypeResult Ty = ParseTypeName();
+  TypeResult Ty = ParseTypeName(nullptr, DeclaratorContext::TemplateArg);
   if (Ty.isInvalid()) {
 SkipUntil(tok::comma, StopAtSemi);
 SkipUntil(tok::r_paren, StopAtSemi);

>From 4c58f4f351a17cf4bf3c9d0ccfa118d0fe3a52de Mon Sep 17 00:00:00 2001
From: Amirreza Ashouri 
Date: Sun, 11 Feb 2024 20:35:04 +0330
Subject: [PATCH 2/5] [clang] Fix the failing test in #81298

---
 clang/test/Sema/static-assert.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/test/Sema/static-assert.c b/clang/test/Sema/static-assert.c
index 4e9e6b7ee558bd..7e1ce135cbd995 100644
--- a/clang/test/Sema/static-assert.c
+++ b/clang/test/Sema/static-assert.c
@@ -57,7 +57,7 @@ UNION(char[2], short) u2 = { .one = { 'a', 'b' } }; // 
ext-warning 3 {{'_Static_
 typedef UNION(char, short) U3; // expected-error {{static assertion failed due 
to requirement 'sizeof(char) == sizeof(short)': type size mismatch}} \
// expected-note{{evaluates to '1 == 2'}} \
// ext-warning 3 {{'_Static_assert' is a C11 
extension}}
-typedef UNION(float, 0.5f) U4; // expected-error {{expected a type}} \
+typedef UNION(float, 0.5f) U4; // expected-error-re type name requires a 
specifier or qualifier|expected a type \
// ext-warning 3 {{'_Static_assert' is a C11 
extension}}
 
 // After defining the assert macro in MS-compatibility mode, we should

>From 03c2cfb73fc291ecfc5318077b295a6e38cd9869 Mon Sep 17 00:00:00 2001
From: Amirreza Ashouri 
Date: Mon, 12 Feb 2024 23:47:33 +0330
Subject: [PATCH 3/5] Add a release note.

---
 clang/docs/ReleaseNotes.rst | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 32440ee64e3ebe..0beb10af709804 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -217,6 +217,8 @@ Bug Fixes to C++ Support
   Fixes (`#80971 ICE when explicit object parameter be a function parameter 
pack`)
 - Fixed a bug where abbreviated function templates would append their invented 
template parameters to
   an empty template parameter lists.
+- Fix parsing of abominable function types inside type traits. 
+  Fixes (`#77585 `_)
 
 Bug Fixes to AST Handling
 ^

>From 0de0aa09fb5f45fcde688d988377582b9257b6b8 Mon Sep 17 00:00:00 2001
From: Amirreza Ashouri 
Date: Tue, 13 Feb 2024 01:19:27 +0330
Subject: [PATCH 4/5] Remove trailing white space in ReleaseNotes.rst.

---
 clang/docs/ReleaseNotes.rst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 0beb10af709804..55f3faea365a07 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -217,7 +217,7 @@ Bug Fixes to C++ Support
   Fixes (`#80971 ICE when explicit object parameter be a function parameter 
pack`)
 - Fixed a bug where abbreviated function templates would append their invented 
template parameters to
   an empty template parameter lists.
-- Fix parsing of abominable function types inside type traits. 
+- Fix parsing of abominable function types inside type traits.
   Fixes (`#77585 `_)
 
 Bug Fixes to AST Handling

>

[clang] [clang] Support `__is_trivially_copyable(int()&)==false` (PR #81298)

2024-02-22 Thread via cfe-commits

https://github.com/cor3ntin edited 
https://github.com/llvm/llvm-project/pull/81298
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Support `__is_trivially_copyable(int()&)==false` (PR #81298)

2024-02-22 Thread via cfe-commits

https://github.com/cor3ntin commented:

This is going to need additional tests (ie a test for 
`__is_trivially_copyable(int()&)` would be a good start!)

https://github.com/llvm/llvm-project/pull/81298
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Support `__is_trivially_copyable(int()&)==false` (PR #81298)

2024-02-22 Thread via cfe-commits


@@ -3941,7 +3943,7 @@ ExprResult Parser::ParseArrayTypeTrait() {
   if (T.expectAndConsume())
 return ExprError();
 
-  TypeResult Ty = ParseTypeName();
+  TypeResult Ty = ParseTypeName(nullptr, DeclaratorContext::TemplateArg);

cor3ntin wrote:

```suggestion
  TypeResult Ty = ParseTypeName(/*SourceRange=*/nullptr, 
DeclaratorContext::TemplateArg);
```

https://github.com/llvm/llvm-project/pull/81298
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Support `__is_trivially_copyable(int()&)==false` (PR #81298)

2024-02-22 Thread via cfe-commits


@@ -3899,7 +3899,9 @@ ExprResult Parser::ParseTypeTrait() {
   SmallVector Args;
   do {
 // Parse the next type.
-TypeResult Ty = ParseTypeName();
+TypeResult Ty = ParseTypeName(nullptr, getLangOpts().CPlusPlus

cor3ntin wrote:

```suggestion
TypeResult Ty = ParseTypeName(/*SourceRange=*/nullptr, 
getLangOpts().CPlusPlus
```

https://github.com/llvm/llvm-project/pull/81298
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Support `__is_trivially_copyable(int()&)==false` (PR #81298)

2024-02-20 Thread Amirreza Ashouri via cfe-commits

https://github.com/AMP999 updated 
https://github.com/llvm/llvm-project/pull/81298

>From d59c262b31937fdd2b907ec11d7f08e4a385007c Mon Sep 17 00:00:00 2001
From: Amirreza Ashouri 
Date: Fri, 9 Feb 2024 21:55:03 +0330
Subject: [PATCH 1/5] [clang] Support `__is_trivially_copyable(int()&)==false`

IMHO it would be productive to make a similar change for `typeid`,
in `ParseCXXTypeid`, in order to improve Clang's error message for
https://godbolt.org/z/oKKWxeYra
But that might be better done by adding a new DeclaratorContext
specifically for TypeidArg, instead of pretending that the argument
to `typeid` is a template argument, because I don't know what else
that change might affect.

Fixes https://github.com/llvm/llvm-project/issues/77585
---
 clang/lib/Parse/ParseExprCXX.cpp | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/clang/lib/Parse/ParseExprCXX.cpp b/clang/lib/Parse/ParseExprCXX.cpp
index fd262ff31e661a..746a8b2286ac4c 100644
--- a/clang/lib/Parse/ParseExprCXX.cpp
+++ b/clang/lib/Parse/ParseExprCXX.cpp
@@ -3899,7 +3899,9 @@ ExprResult Parser::ParseTypeTrait() {
   SmallVector Args;
   do {
 // Parse the next type.
-TypeResult Ty = ParseTypeName();
+TypeResult Ty = ParseTypeName(nullptr, getLangOpts().CPlusPlus
+   ? DeclaratorContext::TemplateArg
+   : DeclaratorContext::TypeName);
 if (Ty.isInvalid()) {
   Parens.skipToEnd();
   return ExprError();
@@ -3941,7 +3943,7 @@ ExprResult Parser::ParseArrayTypeTrait() {
   if (T.expectAndConsume())
 return ExprError();
 
-  TypeResult Ty = ParseTypeName();
+  TypeResult Ty = ParseTypeName(nullptr, DeclaratorContext::TemplateArg);
   if (Ty.isInvalid()) {
 SkipUntil(tok::comma, StopAtSemi);
 SkipUntil(tok::r_paren, StopAtSemi);

>From 4c58f4f351a17cf4bf3c9d0ccfa118d0fe3a52de Mon Sep 17 00:00:00 2001
From: Amirreza Ashouri 
Date: Sun, 11 Feb 2024 20:35:04 +0330
Subject: [PATCH 2/5] [clang] Fix the failing test in #81298

---
 clang/test/Sema/static-assert.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/test/Sema/static-assert.c b/clang/test/Sema/static-assert.c
index 4e9e6b7ee558bd..7e1ce135cbd995 100644
--- a/clang/test/Sema/static-assert.c
+++ b/clang/test/Sema/static-assert.c
@@ -57,7 +57,7 @@ UNION(char[2], short) u2 = { .one = { 'a', 'b' } }; // 
ext-warning 3 {{'_Static_
 typedef UNION(char, short) U3; // expected-error {{static assertion failed due 
to requirement 'sizeof(char) == sizeof(short)': type size mismatch}} \
// expected-note{{evaluates to '1 == 2'}} \
// ext-warning 3 {{'_Static_assert' is a C11 
extension}}
-typedef UNION(float, 0.5f) U4; // expected-error {{expected a type}} \
+typedef UNION(float, 0.5f) U4; // expected-error-re type name requires a 
specifier or qualifier|expected a type \
// ext-warning 3 {{'_Static_assert' is a C11 
extension}}
 
 // After defining the assert macro in MS-compatibility mode, we should

>From 03c2cfb73fc291ecfc5318077b295a6e38cd9869 Mon Sep 17 00:00:00 2001
From: Amirreza Ashouri 
Date: Mon, 12 Feb 2024 23:47:33 +0330
Subject: [PATCH 3/5] Add a release note.

---
 clang/docs/ReleaseNotes.rst | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 32440ee64e3ebe..0beb10af709804 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -217,6 +217,8 @@ Bug Fixes to C++ Support
   Fixes (`#80971 ICE when explicit object parameter be a function parameter 
pack`)
 - Fixed a bug where abbreviated function templates would append their invented 
template parameters to
   an empty template parameter lists.
+- Fix parsing of abominable function types inside type traits. 
+  Fixes (`#77585 `_)
 
 Bug Fixes to AST Handling
 ^

>From 0de0aa09fb5f45fcde688d988377582b9257b6b8 Mon Sep 17 00:00:00 2001
From: Amirreza Ashouri 
Date: Tue, 13 Feb 2024 01:19:27 +0330
Subject: [PATCH 4/5] Remove trailing white space in ReleaseNotes.rst.

---
 clang/docs/ReleaseNotes.rst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 0beb10af709804..55f3faea365a07 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -217,7 +217,7 @@ Bug Fixes to C++ Support
   Fixes (`#80971 ICE when explicit object parameter be a function parameter 
pack`)
 - Fixed a bug where abbreviated function templates would append their invented 
template parameters to
   an empty template parameter lists.
-- Fix parsing of abominable function types inside type traits. 
+- Fix parsing of abominable function types inside type traits.
   Fixes (`#77585 `_)
 
 Bug Fixes to AST Handling

>

[clang] [clang] Support `__is_trivially_copyable(int()&)==false` (PR #81298)

2024-02-20 Thread Amirreza Ashouri via cfe-commits

https://github.com/AMP999 updated 
https://github.com/llvm/llvm-project/pull/81298

>From d59c262b31937fdd2b907ec11d7f08e4a385007c Mon Sep 17 00:00:00 2001
From: Amirreza Ashouri 
Date: Fri, 9 Feb 2024 21:55:03 +0330
Subject: [PATCH 1/5] [clang] Support `__is_trivially_copyable(int()&)==false`

IMHO it would be productive to make a similar change for `typeid`,
in `ParseCXXTypeid`, in order to improve Clang's error message for
https://godbolt.org/z/oKKWxeYra
But that might be better done by adding a new DeclaratorContext
specifically for TypeidArg, instead of pretending that the argument
to `typeid` is a template argument, because I don't know what else
that change might affect.

Fixes https://github.com/llvm/llvm-project/issues/77585
---
 clang/lib/Parse/ParseExprCXX.cpp | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/clang/lib/Parse/ParseExprCXX.cpp b/clang/lib/Parse/ParseExprCXX.cpp
index fd262ff31e661a..746a8b2286ac4c 100644
--- a/clang/lib/Parse/ParseExprCXX.cpp
+++ b/clang/lib/Parse/ParseExprCXX.cpp
@@ -3899,7 +3899,9 @@ ExprResult Parser::ParseTypeTrait() {
   SmallVector Args;
   do {
 // Parse the next type.
-TypeResult Ty = ParseTypeName();
+TypeResult Ty = ParseTypeName(nullptr, getLangOpts().CPlusPlus
+   ? DeclaratorContext::TemplateArg
+   : DeclaratorContext::TypeName);
 if (Ty.isInvalid()) {
   Parens.skipToEnd();
   return ExprError();
@@ -3941,7 +3943,7 @@ ExprResult Parser::ParseArrayTypeTrait() {
   if (T.expectAndConsume())
 return ExprError();
 
-  TypeResult Ty = ParseTypeName();
+  TypeResult Ty = ParseTypeName(nullptr, DeclaratorContext::TemplateArg);
   if (Ty.isInvalid()) {
 SkipUntil(tok::comma, StopAtSemi);
 SkipUntil(tok::r_paren, StopAtSemi);

>From 4c58f4f351a17cf4bf3c9d0ccfa118d0fe3a52de Mon Sep 17 00:00:00 2001
From: Amirreza Ashouri 
Date: Sun, 11 Feb 2024 20:35:04 +0330
Subject: [PATCH 2/5] [clang] Fix the failing test in #81298

---
 clang/test/Sema/static-assert.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/test/Sema/static-assert.c b/clang/test/Sema/static-assert.c
index 4e9e6b7ee558bd..7e1ce135cbd995 100644
--- a/clang/test/Sema/static-assert.c
+++ b/clang/test/Sema/static-assert.c
@@ -57,7 +57,7 @@ UNION(char[2], short) u2 = { .one = { 'a', 'b' } }; // 
ext-warning 3 {{'_Static_
 typedef UNION(char, short) U3; // expected-error {{static assertion failed due 
to requirement 'sizeof(char) == sizeof(short)': type size mismatch}} \
// expected-note{{evaluates to '1 == 2'}} \
// ext-warning 3 {{'_Static_assert' is a C11 
extension}}
-typedef UNION(float, 0.5f) U4; // expected-error {{expected a type}} \
+typedef UNION(float, 0.5f) U4; // expected-error-re type name requires a 
specifier or qualifier|expected a type \
// ext-warning 3 {{'_Static_assert' is a C11 
extension}}
 
 // After defining the assert macro in MS-compatibility mode, we should

>From 03c2cfb73fc291ecfc5318077b295a6e38cd9869 Mon Sep 17 00:00:00 2001
From: Amirreza Ashouri 
Date: Mon, 12 Feb 2024 23:47:33 +0330
Subject: [PATCH 3/5] Add a release note.

---
 clang/docs/ReleaseNotes.rst | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 32440ee64e3ebe..0beb10af709804 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -217,6 +217,8 @@ Bug Fixes to C++ Support
   Fixes (`#80971 ICE when explicit object parameter be a function parameter 
pack`)
 - Fixed a bug where abbreviated function templates would append their invented 
template parameters to
   an empty template parameter lists.
+- Fix parsing of abominable function types inside type traits. 
+  Fixes (`#77585 `_)
 
 Bug Fixes to AST Handling
 ^

>From 0de0aa09fb5f45fcde688d988377582b9257b6b8 Mon Sep 17 00:00:00 2001
From: Amirreza Ashouri 
Date: Tue, 13 Feb 2024 01:19:27 +0330
Subject: [PATCH 4/5] Remove trailing white space in ReleaseNotes.rst.

---
 clang/docs/ReleaseNotes.rst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 0beb10af709804..55f3faea365a07 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -217,7 +217,7 @@ Bug Fixes to C++ Support
   Fixes (`#80971 ICE when explicit object parameter be a function parameter 
pack`)
 - Fixed a bug where abbreviated function templates would append their invented 
template parameters to
   an empty template parameter lists.
-- Fix parsing of abominable function types inside type traits. 
+- Fix parsing of abominable function types inside type traits.
   Fixes (`#77585 `_)
 
 Bug Fixes to AST Handling

>

[clang] [clang] Support `__is_trivially_copyable(int()&)==false` (PR #81298)

2024-02-12 Thread Eli Friedman via cfe-commits

https://github.com/efriedma-quic updated 
https://github.com/llvm/llvm-project/pull/81298

>From d59c262b31937fdd2b907ec11d7f08e4a385007c Mon Sep 17 00:00:00 2001
From: Amirreza Ashouri 
Date: Fri, 9 Feb 2024 21:55:03 +0330
Subject: [PATCH 1/4] [clang] Support `__is_trivially_copyable(int()&)==false`

IMHO it would be productive to make a similar change for `typeid`,
in `ParseCXXTypeid`, in order to improve Clang's error message for
https://godbolt.org/z/oKKWxeYra
But that might be better done by adding a new DeclaratorContext
specifically for TypeidArg, instead of pretending that the argument
to `typeid` is a template argument, because I don't know what else
that change might affect.

Fixes https://github.com/llvm/llvm-project/issues/77585
---
 clang/lib/Parse/ParseExprCXX.cpp | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/clang/lib/Parse/ParseExprCXX.cpp b/clang/lib/Parse/ParseExprCXX.cpp
index fd262ff31e661a..746a8b2286ac4c 100644
--- a/clang/lib/Parse/ParseExprCXX.cpp
+++ b/clang/lib/Parse/ParseExprCXX.cpp
@@ -3899,7 +3899,9 @@ ExprResult Parser::ParseTypeTrait() {
   SmallVector Args;
   do {
 // Parse the next type.
-TypeResult Ty = ParseTypeName();
+TypeResult Ty = ParseTypeName(nullptr, getLangOpts().CPlusPlus
+   ? DeclaratorContext::TemplateArg
+   : DeclaratorContext::TypeName);
 if (Ty.isInvalid()) {
   Parens.skipToEnd();
   return ExprError();
@@ -3941,7 +3943,7 @@ ExprResult Parser::ParseArrayTypeTrait() {
   if (T.expectAndConsume())
 return ExprError();
 
-  TypeResult Ty = ParseTypeName();
+  TypeResult Ty = ParseTypeName(nullptr, DeclaratorContext::TemplateArg);
   if (Ty.isInvalid()) {
 SkipUntil(tok::comma, StopAtSemi);
 SkipUntil(tok::r_paren, StopAtSemi);

>From 4c58f4f351a17cf4bf3c9d0ccfa118d0fe3a52de Mon Sep 17 00:00:00 2001
From: Amirreza Ashouri 
Date: Sun, 11 Feb 2024 20:35:04 +0330
Subject: [PATCH 2/4] [clang] Fix the failing test in #81298

---
 clang/test/Sema/static-assert.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/test/Sema/static-assert.c b/clang/test/Sema/static-assert.c
index 4e9e6b7ee558bd..7e1ce135cbd995 100644
--- a/clang/test/Sema/static-assert.c
+++ b/clang/test/Sema/static-assert.c
@@ -57,7 +57,7 @@ UNION(char[2], short) u2 = { .one = { 'a', 'b' } }; // 
ext-warning 3 {{'_Static_
 typedef UNION(char, short) U3; // expected-error {{static assertion failed due 
to requirement 'sizeof(char) == sizeof(short)': type size mismatch}} \
// expected-note{{evaluates to '1 == 2'}} \
// ext-warning 3 {{'_Static_assert' is a C11 
extension}}
-typedef UNION(float, 0.5f) U4; // expected-error {{expected a type}} \
+typedef UNION(float, 0.5f) U4; // expected-error-re type name requires a 
specifier or qualifier|expected a type \
// ext-warning 3 {{'_Static_assert' is a C11 
extension}}
 
 // After defining the assert macro in MS-compatibility mode, we should

>From 03c2cfb73fc291ecfc5318077b295a6e38cd9869 Mon Sep 17 00:00:00 2001
From: Amirreza Ashouri 
Date: Mon, 12 Feb 2024 23:47:33 +0330
Subject: [PATCH 3/4] Add a release note.

---
 clang/docs/ReleaseNotes.rst | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 32440ee64e3ebe..0beb10af709804 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -217,6 +217,8 @@ Bug Fixes to C++ Support
   Fixes (`#80971 ICE when explicit object parameter be a function parameter 
pack`)
 - Fixed a bug where abbreviated function templates would append their invented 
template parameters to
   an empty template parameter lists.
+- Fix parsing of abominable function types inside type traits. 
+  Fixes (`#77585 `_)
 
 Bug Fixes to AST Handling
 ^

>From 0de0aa09fb5f45fcde688d988377582b9257b6b8 Mon Sep 17 00:00:00 2001
From: Amirreza Ashouri 
Date: Tue, 13 Feb 2024 01:19:27 +0330
Subject: [PATCH 4/4] Remove trailing white space in ReleaseNotes.rst.

---
 clang/docs/ReleaseNotes.rst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 0beb10af709804..55f3faea365a07 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -217,7 +217,7 @@ Bug Fixes to C++ Support
   Fixes (`#80971 ICE when explicit object parameter be a function parameter 
pack`)
 - Fixed a bug where abbreviated function templates would append their invented 
template parameters to
   an empty template parameter lists.
-- Fix parsing of abominable function types inside type traits. 
+- Fix parsing of abominable function types inside type traits.
   Fixes (`#77585 `_)
 
 Bug Fixes to AST Hand

[clang] [clang] Support `__is_trivially_copyable(int()&)==false` (PR #81298)

2024-02-12 Thread Amirreza Ashouri via cfe-commits

https://github.com/AMP999 updated 
https://github.com/llvm/llvm-project/pull/81298

>From d59c262b31937fdd2b907ec11d7f08e4a385007c Mon Sep 17 00:00:00 2001
From: Amirreza Ashouri 
Date: Fri, 9 Feb 2024 21:55:03 +0330
Subject: [PATCH 1/3] [clang] Support `__is_trivially_copyable(int()&)==false`

IMHO it would be productive to make a similar change for `typeid`,
in `ParseCXXTypeid`, in order to improve Clang's error message for
https://godbolt.org/z/oKKWxeYra
But that might be better done by adding a new DeclaratorContext
specifically for TypeidArg, instead of pretending that the argument
to `typeid` is a template argument, because I don't know what else
that change might affect.

Fixes https://github.com/llvm/llvm-project/issues/77585
---
 clang/lib/Parse/ParseExprCXX.cpp | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/clang/lib/Parse/ParseExprCXX.cpp b/clang/lib/Parse/ParseExprCXX.cpp
index fd262ff31e661a..746a8b2286ac4c 100644
--- a/clang/lib/Parse/ParseExprCXX.cpp
+++ b/clang/lib/Parse/ParseExprCXX.cpp
@@ -3899,7 +3899,9 @@ ExprResult Parser::ParseTypeTrait() {
   SmallVector Args;
   do {
 // Parse the next type.
-TypeResult Ty = ParseTypeName();
+TypeResult Ty = ParseTypeName(nullptr, getLangOpts().CPlusPlus
+   ? DeclaratorContext::TemplateArg
+   : DeclaratorContext::TypeName);
 if (Ty.isInvalid()) {
   Parens.skipToEnd();
   return ExprError();
@@ -3941,7 +3943,7 @@ ExprResult Parser::ParseArrayTypeTrait() {
   if (T.expectAndConsume())
 return ExprError();
 
-  TypeResult Ty = ParseTypeName();
+  TypeResult Ty = ParseTypeName(nullptr, DeclaratorContext::TemplateArg);
   if (Ty.isInvalid()) {
 SkipUntil(tok::comma, StopAtSemi);
 SkipUntil(tok::r_paren, StopAtSemi);

>From 4c58f4f351a17cf4bf3c9d0ccfa118d0fe3a52de Mon Sep 17 00:00:00 2001
From: Amirreza Ashouri 
Date: Sun, 11 Feb 2024 20:35:04 +0330
Subject: [PATCH 2/3] [clang] Fix the failing test in #81298

---
 clang/test/Sema/static-assert.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/test/Sema/static-assert.c b/clang/test/Sema/static-assert.c
index 4e9e6b7ee558bd..7e1ce135cbd995 100644
--- a/clang/test/Sema/static-assert.c
+++ b/clang/test/Sema/static-assert.c
@@ -57,7 +57,7 @@ UNION(char[2], short) u2 = { .one = { 'a', 'b' } }; // 
ext-warning 3 {{'_Static_
 typedef UNION(char, short) U3; // expected-error {{static assertion failed due 
to requirement 'sizeof(char) == sizeof(short)': type size mismatch}} \
// expected-note{{evaluates to '1 == 2'}} \
// ext-warning 3 {{'_Static_assert' is a C11 
extension}}
-typedef UNION(float, 0.5f) U4; // expected-error {{expected a type}} \
+typedef UNION(float, 0.5f) U4; // expected-error-re type name requires a 
specifier or qualifier|expected a type \
// ext-warning 3 {{'_Static_assert' is a C11 
extension}}
 
 // After defining the assert macro in MS-compatibility mode, we should

>From 03c2cfb73fc291ecfc5318077b295a6e38cd9869 Mon Sep 17 00:00:00 2001
From: Amirreza Ashouri 
Date: Mon, 12 Feb 2024 23:47:33 +0330
Subject: [PATCH 3/3] Add a release note.

---
 clang/docs/ReleaseNotes.rst | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 32440ee64e3ebe..0beb10af709804 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -217,6 +217,8 @@ Bug Fixes to C++ Support
   Fixes (`#80971 ICE when explicit object parameter be a function parameter 
pack`)
 - Fixed a bug where abbreviated function templates would append their invented 
template parameters to
   an empty template parameter lists.
+- Fix parsing of abominable function types inside type traits. 
+  Fixes (`#77585 `_)
 
 Bug Fixes to AST Handling
 ^

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


[clang] [clang] Support `__is_trivially_copyable(int()&)==false` (PR #81298)

2024-02-12 Thread Aaron Ballman via cfe-commits


@@ -57,7 +57,7 @@ UNION(char[2], short) u2 = { .one = { 'a', 'b' } }; // 
ext-warning 3 {{'_Static_
 typedef UNION(char, short) U3; // expected-error {{static assertion failed due 
to requirement 'sizeof(char) == sizeof(short)': type size mismatch}} \
// expected-note{{evaluates to '1 == 2'}} \
// ext-warning 3 {{'_Static_assert' is a C11 
extension}}
-typedef UNION(float, 0.5f) U4; // expected-error {{expected a type}} \
+typedef UNION(float, 0.5f) U4; // expected-error-re type name requires a 
specifier or qualifier|expected a type \

AaronBallman wrote:

I think there's an 'or' because the RUN lines run this in both C and C++ mode, 
so you get different diagnostics. A better way to express that is with a 
different `-verify` prefix on the RUN lines so that you can do something like 
`cpp-error {{blah}}` and `c-error {{blah}}` to make it more clear what's 
happening.

https://github.com/llvm/llvm-project/pull/81298
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Support `__is_trivially_copyable(int()&)==false` (PR #81298)

2024-02-12 Thread Erich Keane via cfe-commits


@@ -57,7 +57,7 @@ UNION(char[2], short) u2 = { .one = { 'a', 'b' } }; // 
ext-warning 3 {{'_Static_
 typedef UNION(char, short) U3; // expected-error {{static assertion failed due 
to requirement 'sizeof(char) == sizeof(short)': type size mismatch}} \
// expected-note{{evaluates to '1 == 2'}} \
// ext-warning 3 {{'_Static_assert' is a C11 
extension}}
-typedef UNION(float, 0.5f) U4; // expected-error {{expected a type}} \
+typedef UNION(float, 0.5f) U4; // expected-error-re type name requires a 
specifier or qualifier|expected a type \

erichkeane wrote:

This test doesn't seem right... why is there an 'or' here?

https://github.com/llvm/llvm-project/pull/81298
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Support `__is_trivially_copyable(int()&)==false` (PR #81298)

2024-02-12 Thread Erich Keane via cfe-commits

https://github.com/erichkeane commented:

This would need a release note + I think it needs better testing.  
@AaronBallman might wish to take a look as well, this is his code ownership.

https://github.com/llvm/llvm-project/pull/81298
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Support `__is_trivially_copyable(int()&)==false` (PR #81298)

2024-02-12 Thread Erich Keane via cfe-commits

https://github.com/erichkeane edited 
https://github.com/llvm/llvm-project/pull/81298
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Support `__is_trivially_copyable(int()&)==false` (PR #81298)

2024-02-11 Thread Amirreza Ashouri via cfe-commits

https://github.com/AMP999 updated 
https://github.com/llvm/llvm-project/pull/81298

>From d59c262b31937fdd2b907ec11d7f08e4a385007c Mon Sep 17 00:00:00 2001
From: Amirreza Ashouri 
Date: Fri, 9 Feb 2024 21:55:03 +0330
Subject: [PATCH 1/2] [clang] Support `__is_trivially_copyable(int()&)==false`

IMHO it would be productive to make a similar change for `typeid`,
in `ParseCXXTypeid`, in order to improve Clang's error message for
https://godbolt.org/z/oKKWxeYra
But that might be better done by adding a new DeclaratorContext
specifically for TypeidArg, instead of pretending that the argument
to `typeid` is a template argument, because I don't know what else
that change might affect.

Fixes https://github.com/llvm/llvm-project/issues/77585
---
 clang/lib/Parse/ParseExprCXX.cpp | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/clang/lib/Parse/ParseExprCXX.cpp b/clang/lib/Parse/ParseExprCXX.cpp
index fd262ff31e661a..746a8b2286ac4c 100644
--- a/clang/lib/Parse/ParseExprCXX.cpp
+++ b/clang/lib/Parse/ParseExprCXX.cpp
@@ -3899,7 +3899,9 @@ ExprResult Parser::ParseTypeTrait() {
   SmallVector Args;
   do {
 // Parse the next type.
-TypeResult Ty = ParseTypeName();
+TypeResult Ty = ParseTypeName(nullptr, getLangOpts().CPlusPlus
+   ? DeclaratorContext::TemplateArg
+   : DeclaratorContext::TypeName);
 if (Ty.isInvalid()) {
   Parens.skipToEnd();
   return ExprError();
@@ -3941,7 +3943,7 @@ ExprResult Parser::ParseArrayTypeTrait() {
   if (T.expectAndConsume())
 return ExprError();
 
-  TypeResult Ty = ParseTypeName();
+  TypeResult Ty = ParseTypeName(nullptr, DeclaratorContext::TemplateArg);
   if (Ty.isInvalid()) {
 SkipUntil(tok::comma, StopAtSemi);
 SkipUntil(tok::r_paren, StopAtSemi);

>From 4c58f4f351a17cf4bf3c9d0ccfa118d0fe3a52de Mon Sep 17 00:00:00 2001
From: Amirreza Ashouri 
Date: Sun, 11 Feb 2024 20:35:04 +0330
Subject: [PATCH 2/2] [clang] Fix the failing test in #81298

---
 clang/test/Sema/static-assert.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/test/Sema/static-assert.c b/clang/test/Sema/static-assert.c
index 4e9e6b7ee558bd..7e1ce135cbd995 100644
--- a/clang/test/Sema/static-assert.c
+++ b/clang/test/Sema/static-assert.c
@@ -57,7 +57,7 @@ UNION(char[2], short) u2 = { .one = { 'a', 'b' } }; // 
ext-warning 3 {{'_Static_
 typedef UNION(char, short) U3; // expected-error {{static assertion failed due 
to requirement 'sizeof(char) == sizeof(short)': type size mismatch}} \
// expected-note{{evaluates to '1 == 2'}} \
// ext-warning 3 {{'_Static_assert' is a C11 
extension}}
-typedef UNION(float, 0.5f) U4; // expected-error {{expected a type}} \
+typedef UNION(float, 0.5f) U4; // expected-error-re type name requires a 
specifier or qualifier|expected a type \
// ext-warning 3 {{'_Static_assert' is a C11 
extension}}
 
 // After defining the assert macro in MS-compatibility mode, we should

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


[clang] [clang] Support `__is_trivially_copyable(int()&)==false` (PR #81298)

2024-02-09 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Amirreza Ashouri (AMP999)


Changes

IMHO it would be productive to make a similar change for `typeid`, in 
`ParseCXXTypeid`, in order to improve Clang's error message for 
https://godbolt.org/z/oKKWxeYra
But that might be better done by adding a new DeclaratorContext specifically 
for TypeidArg, instead of pretending that the argument to `typeid` is a 
template argument, because I don't know what else that change might affect.

Fixes https://github.com/llvm/llvm-project/issues/77585

---
Full diff: https://github.com/llvm/llvm-project/pull/81298.diff


1 Files Affected:

- (modified) clang/lib/Parse/ParseExprCXX.cpp (+4-2) 


``diff
diff --git a/clang/lib/Parse/ParseExprCXX.cpp b/clang/lib/Parse/ParseExprCXX.cpp
index fd262ff31e661a..746a8b2286ac4c 100644
--- a/clang/lib/Parse/ParseExprCXX.cpp
+++ b/clang/lib/Parse/ParseExprCXX.cpp
@@ -3899,7 +3899,9 @@ ExprResult Parser::ParseTypeTrait() {
   SmallVector Args;
   do {
 // Parse the next type.
-TypeResult Ty = ParseTypeName();
+TypeResult Ty = ParseTypeName(nullptr, getLangOpts().CPlusPlus
+   ? DeclaratorContext::TemplateArg
+   : DeclaratorContext::TypeName);
 if (Ty.isInvalid()) {
   Parens.skipToEnd();
   return ExprError();
@@ -3941,7 +3943,7 @@ ExprResult Parser::ParseArrayTypeTrait() {
   if (T.expectAndConsume())
 return ExprError();
 
-  TypeResult Ty = ParseTypeName();
+  TypeResult Ty = ParseTypeName(nullptr, DeclaratorContext::TemplateArg);
   if (Ty.isInvalid()) {
 SkipUntil(tok::comma, StopAtSemi);
 SkipUntil(tok::r_paren, StopAtSemi);

``




https://github.com/llvm/llvm-project/pull/81298
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits