[clang] [Clang] Fix some assertions not looking through type sugar (PR #92299)

2024-07-17 Thread via cfe-commits

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


[clang] [Clang] Fix some assertions not looking through type sugar (PR #92299)

2024-07-17 Thread via cfe-commits

https://github.com/cor3ntin updated 
https://github.com/llvm/llvm-project/pull/92299

>From b6cb1c53a20637255bf869617b60155bfb636c60 Mon Sep 17 00:00:00 2001
From: Mital Ashok 
Date: Wed, 15 May 2024 18:50:14 +0100
Subject: [PATCH] [Clang] Fix some assertions not looking through type sugar

Fixes #92284
---
 clang/lib/AST/ExprConstant.cpp |  2 +-
 clang/lib/Sema/SemaInit.cpp|  2 +-
 clang/test/SemaCXX/paren-list-agg-init.cpp | 16 
 3 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index f1aa19e4409e1..dca2b5d016738 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -11420,7 +11420,7 @@ bool ArrayExprEvaluator::VisitCXXConstructExpr(const 
CXXConstructExpr *E,
 
 bool ArrayExprEvaluator::VisitCXXParenListInitExpr(
 const CXXParenListInitExpr *E) {
-  assert(dyn_cast(E->getType()) &&
+  assert(E->getType()->isConstantArrayType() &&
  "Expression result is not a constant array type");
 
   return VisitCXXParenListOrInitListExpr(E, E->getInitExprs(),
diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp
index 708286e192f9c..77d0075fbfd88 100644
--- a/clang/lib/Sema/SemaInit.cpp
+++ b/clang/lib/Sema/SemaInit.cpp
@@ -5511,7 +5511,7 @@ static void TryOrBuildParenListInitialization(
   << SE->getSourceRange();
   return;
 } else {
-  assert(isa(Entity.getType()));
+  assert(Entity.getType()->isIncompleteArrayType());
   ArrayLength = Args.size();
 }
 EntityIndexToProcess = ArrayLength;
diff --git a/clang/test/SemaCXX/paren-list-agg-init.cpp 
b/clang/test/SemaCXX/paren-list-agg-init.cpp
index c1964a5a9eb00..e8a9cd7e0509c 100644
--- a/clang/test/SemaCXX/paren-list-agg-init.cpp
+++ b/clang/test/SemaCXX/paren-list-agg-init.cpp
@@ -313,3 +313,19 @@ namespace GH63903 {
   constexpr S s(0); // beforecxx20-warning {{aggregate initialization of type 
'const S' from a parenthesized list of values is a C++20 extension}} \
 // expected-error {{constexpr variable 's' must be 
initialized by a constant expression}}
 }
+
+namespace GH92284 {
+  using T = int[1]; T x(42);
+// beforecxx20-warning@-1 {{aggregate initialization of type 'T' (aka 
'int[1]') from a parenthesized list of values is a C++20 extension}}
+  using Ta = int[2]; Ta a(42);
+// beforecxx20-warning@-1 {{aggregate initialization of type 'Ta' (aka 
'int[2]') from a parenthesized list of values is a C++20 extension}}
+  using Tb = int[2]; Tb b(42,43);
+// beforecxx20-warning@-1 {{aggregate initialization of type 'Tb' (aka 
'int[2]') from a parenthesized list of values is a C++20 extension}}
+  using Tc = int[]; Tc c(42);
+// beforecxx20-warning@-1 {{aggregate initialization of type 'int[1]' from a 
parenthesized list of values is a C++20 extension}}
+  using Td = int[]; Td d(42,43);
+// beforecxx20-warning@-1 {{aggregate initialization of type 'int[2]' from a 
parenthesized list of values is a C++20 extension}}
+  template using ThroughAlias = T[Sz];
+  ThroughAlias e(42);
+// beforecxx20-warning@-1 {{aggregate initialization of type 
'ThroughAlias' (aka 'int[1]') from a parenthesized list of values is a 
C++20 extension}}
+}

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


[clang] [Clang] Fix some assertions not looking through type sugar (PR #92299)

2024-07-17 Thread via cfe-commits

cor3ntin wrote:

@MitalAshok ping

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


[clang] [Clang] Fix some assertions not looking through type sugar (PR #92299)

2024-05-15 Thread Matheus Izvekov via cfe-commits

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

LGTM, Thanks!

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


[clang] [Clang] Fix some assertions not looking through type sugar (PR #92299)

2024-05-15 Thread Mital Ashok via cfe-commits

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