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

via cfe-commits cfe-commits at lists.llvm.org
Fri Feb 9 10:40:50 PST 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Amirreza Ashouri (AMP999)

<details>
<summary>Changes</summary>

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<ParsedType, 2> 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);

``````````

</details>


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


More information about the cfe-commits mailing list