[clang] [Clang][Sema] Do not accept "vector _Complex" for AltiVec/ZVector (PR #90467)

2024-04-30 Thread Ulrich Weigand via cfe-commits

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


[clang] [Clang][Sema] Do not accept "vector _Complex" for AltiVec/ZVector (PR #90467)

2024-04-30 Thread Chen Zheng via cfe-commits

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

LGTM. Thanks!

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


[clang] [Clang][Sema] Do not accept "vector _Complex" for AltiVec/ZVector (PR #90467)

2024-04-30 Thread Ulrich Weigand via cfe-commits


@@ -1191,6 +1191,10 @@ void DeclSpec::Finish(Sema , const PrintingPolicy 
) {
 
   // Validate and finalize AltiVec vector declspec.
   if (TypeAltiVecVector) {
+// Complex vector types are not supported.
+if (TypeSpecComplex != TSC_unspecified)
+  S.Diag(TSCLoc, diag::err_invalid_vector_complex_decl_spec);

uweigand wrote:

Makes sense.  I've updated the patches.

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


[clang] [Clang][Sema] Do not accept "vector _Complex" for AltiVec/ZVector (PR #90467)

2024-04-30 Thread Ulrich Weigand via cfe-commits

https://github.com/uweigand updated 
https://github.com/llvm/llvm-project/pull/90467

>From 7f13179745ccc31ceca223c03c6b75fa46b4fe37 Mon Sep 17 00:00:00 2001
From: Ulrich Weigand 
Date: Mon, 29 Apr 2024 15:04:31 +0200
Subject: [PATCH] [Clang][Sema] Do not accept "vector _Complex" for
 AltiVec/ZVector

The AltiVec (POWER) and ZVector (IBM Z) language extensions do
not support using the "vector" keyword when the element type is
a complex type, but current code does not verify this.

Add a Sema check and diagnostic for this case.

Fixes: https://github.com/llvm/llvm-project/issues/88399
---
 clang/include/clang/Basic/DiagnosticSemaKinds.td | 2 ++
 clang/lib/Sema/DeclSpec.cpp  | 5 -
 clang/test/Parser/altivec.c  | 6 ++
 clang/test/Parser/cxx-altivec.cpp| 6 ++
 clang/test/Sema/zvector.c| 8 
 clang/test/Sema/zvector2.c   | 4 
 6 files changed, 30 insertions(+), 1 deletion(-)

diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index fdca82934cb4dc..8853739969a4ca 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -307,6 +307,8 @@ def err_invalid_vector_long_long_decl_spec : Error <
   "POWER7 or later) to be enabled">;
 def err_invalid_vector_long_double_decl_spec : Error<
   "cannot use 'long double' with '__vector'">;
+def err_invalid_vector_complex_decl_spec : Error<
+  "cannot use '_Complex' with '__vector'">;
 def warn_vector_long_decl_spec_combination : Warning<
   "Use of 'long' with '__vector' is deprecated">, InGroup;
 
diff --git a/clang/lib/Sema/DeclSpec.cpp b/clang/lib/Sema/DeclSpec.cpp
index 5f63c857c43067..60e81890257002 100644
--- a/clang/lib/Sema/DeclSpec.cpp
+++ b/clang/lib/Sema/DeclSpec.cpp
@@ -1202,7 +1202,10 @@ void DeclSpec::Finish(Sema , const PrintingPolicy 
) {
 !S.Context.getTargetInfo().hasFeature("power8-vector"))
   S.Diag(TSTLoc, diag::err_invalid_vector_int128_decl_spec);
 
-if (TypeAltiVecBool) {
+// Complex vector types are not supported.
+if (TypeSpecComplex != TSC_unspecified)
+  S.Diag(TSCLoc, diag::err_invalid_vector_complex_decl_spec);
+else if (TypeAltiVecBool) {
   // Sign specifiers are not allowed with vector bool. (PIM 2.1)
   if (getTypeSpecSign() != TypeSpecifierSign::Unspecified) {
 S.Diag(TSSLoc, diag::err_invalid_vector_bool_decl_spec)
diff --git a/clang/test/Parser/altivec.c b/clang/test/Parser/altivec.c
index daee5eae4d8430..445369f0dc0660 100644
--- a/clang/test/Parser/altivec.c
+++ b/clang/test/Parser/altivec.c
@@ -110,6 +110,12 @@ vector __bool long long v_bll4;  // expected-error 
{{use of 'long long' with
 #endif
 __vector long double  vv_ld3;// expected-error {{cannot use 'long 
double' with '__vector'}}
 vector long double  v_ld4;   // expected-error {{cannot use 'long 
double' with '__vector'}}
+vector float _Complex v_cf;  // expected-error {{cannot use '_Complex' 
with '__vector'}}
+vector double _Complex v_cd; // expected-error {{cannot use '_Complex' 
with '__vector'}}
+vector long double _Complex v_cld;   // expected-error {{cannot use '_Complex' 
with '__vector'}}
+__vector float _Complex v_cf2;   // expected-error {{cannot use '_Complex' 
with '__vector'}}
+__vector double _Complex v_cd2;  // expected-error {{cannot use '_Complex' 
with '__vector'}}
+__vector long double _Complex v_cld2;// expected-error {{cannot use '_Complex' 
with '__vector'}}
 vector bool float v_bf;  // expected-error {{cannot use 'float' 
with '__vector bool'}}
 vector bool double v_bd; // expected-error {{cannot use 'double' 
with '__vector bool'}}
 vector bool pixel v_bp;  // expected-error {{cannot use '__pixel' 
with '__vector bool'}}
diff --git a/clang/test/Parser/cxx-altivec.cpp 
b/clang/test/Parser/cxx-altivec.cpp
index 6da36663422b49..5cb760dababbb6 100644
--- a/clang/test/Parser/cxx-altivec.cpp
+++ b/clang/test/Parser/cxx-altivec.cpp
@@ -111,6 +111,12 @@ vector __bool long long v_bll4;  // expected-error 
{{use of 'long long' with
 #endif
 __vector long double  vv_ld3;// expected-error {{cannot use 'long 
double' with '__vector'}}
 vector long double  v_ld4;   // expected-error {{cannot use 'long 
double' with '__vector'}}
+vector float _Complex v_cf;  // expected-error {{cannot use '_Complex' 
with '__vector'}}
+vector double _Complex v_cd; // expected-error {{cannot use '_Complex' 
with '__vector'}}
+vector long double _Complex v_cld;   // expected-error {{cannot use '_Complex' 
with '__vector'}}
+__vector float _Complex v_cf2;   // expected-error {{cannot use '_Complex' 
with '__vector'}}
+__vector double _Complex v_cd2;  // expected-error {{cannot use '_Complex' 
with '__vector'}}
+__vector long double _Complex v_cld2;// expected-error 

[clang] [Clang][Sema] Do not accept "vector _Complex" for AltiVec/ZVector (PR #90467)

2024-04-29 Thread Chen Zheng via cfe-commits


@@ -111,6 +111,20 @@ vector __bool long long v_bll4;  // expected-error 
{{use of 'long long' with
 #endif
 __vector long double  vv_ld3;// expected-error {{cannot use 'long 
double' with '__vector'}}
 vector long double  v_ld4;   // expected-error {{cannot use 'long 
double' with '__vector'}}
+vector float _Complex v_cf;  // expected-error {{cannot use '_Complex' 
with '__vector'}}
+vector double _Complex v_cd; // expected-error {{cannot use '_Complex' 
with '__vector'}}
+#ifndef __VSX__
+ // expected-error@-2 {{use of 'double' 
with '__vector' requires VSX support to be enabled (available on POWER7 or 
later)}}
+#endif
+vector long double _Complex v_cld;   // expected-error {{cannot use '_Complex' 
with '__vector'}}
+ // expected-error@-1 {{cannot use 'long 
double' with '__vector'}}
+__vector float _Complex v_cf2;   // expected-error {{cannot use '_Complex' 
with '__vector'}}
+__vector double _Complex v_cd2;  // expected-error {{cannot use '_Complex' 
with '__vector'}}
+#ifndef __VSX__
+ // expected-error@-2 {{use of 'double' 
with '__vector' requires VSX support to be enabled (available on POWER7 or 
later)}}

chenzheng1030 wrote:

Error message `cannot use '_Complex' with '__vector'` sounds like good enough. 
This error message is not accurate at all?

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


[clang] [Clang][Sema] Do not accept "vector _Complex" for AltiVec/ZVector (PR #90467)

2024-04-29 Thread Chen Zheng via cfe-commits


@@ -1191,6 +1191,10 @@ void DeclSpec::Finish(Sema , const PrintingPolicy 
) {
 
   // Validate and finalize AltiVec vector declspec.
   if (TypeAltiVecVector) {
+// Complex vector types are not supported.
+if (TypeSpecComplex != TSC_unspecified)
+  S.Diag(TSCLoc, diag::err_invalid_vector_complex_decl_spec);

chenzheng1030 wrote:

Should we stop diagnosing other errors in this function?

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


[clang] [Clang][Sema] Do not accept "vector _Complex" for AltiVec/ZVector (PR #90467)

2024-04-29 Thread Chen Zheng via cfe-commits

https://github.com/chenzheng1030 commented:

Thanks very much for taking care of PPC.

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


[clang] [Clang][Sema] Do not accept "vector _Complex" for AltiVec/ZVector (PR #90467)

2024-04-29 Thread Chen Zheng via cfe-commits

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


[clang] [Clang][Sema] Do not accept "vector _Complex" for AltiVec/ZVector (PR #90467)

2024-04-29 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Ulrich Weigand (uweigand)


Changes

The AltiVec (POWER) and ZVector (IBM Z) language extensions do not support 
using the "vector" keyword when the element type is a complex type, but current 
code does not verify this.

Add a Sema check and diagnostic for this case.

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

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


6 Files Affected:

- (modified) clang/include/clang/Basic/DiagnosticSemaKinds.td (+2) 
- (modified) clang/lib/Sema/DeclSpec.cpp (+4) 
- (modified) clang/test/Parser/altivec.c (+14) 
- (modified) clang/test/Parser/cxx-altivec.cpp (+14) 
- (modified) clang/test/Sema/zvector.c (+12) 
- (modified) clang/test/Sema/zvector2.c (+4) 


``diff
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index fdca82934cb4dc..8853739969a4ca 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -307,6 +307,8 @@ def err_invalid_vector_long_long_decl_spec : Error <
   "POWER7 or later) to be enabled">;
 def err_invalid_vector_long_double_decl_spec : Error<
   "cannot use 'long double' with '__vector'">;
+def err_invalid_vector_complex_decl_spec : Error<
+  "cannot use '_Complex' with '__vector'">;
 def warn_vector_long_decl_spec_combination : Warning<
   "Use of 'long' with '__vector' is deprecated">, InGroup;
 
diff --git a/clang/lib/Sema/DeclSpec.cpp b/clang/lib/Sema/DeclSpec.cpp
index 5f63c857c43067..71225a7ed5ee62 100644
--- a/clang/lib/Sema/DeclSpec.cpp
+++ b/clang/lib/Sema/DeclSpec.cpp
@@ -1191,6 +1191,10 @@ void DeclSpec::Finish(Sema , const PrintingPolicy 
) {
 
   // Validate and finalize AltiVec vector declspec.
   if (TypeAltiVecVector) {
+// Complex vector types are not supported.
+if (TypeSpecComplex != TSC_unspecified)
+  S.Diag(TSCLoc, diag::err_invalid_vector_complex_decl_spec);
+
 // No vector long long without VSX (or ZVector).
 if ((getTypeSpecWidth() == TypeSpecifierWidth::LongLong) &&
 !S.Context.getTargetInfo().hasFeature("vsx") &&
diff --git a/clang/test/Parser/altivec.c b/clang/test/Parser/altivec.c
index daee5eae4d8430..f63a2bfa6abdc3 100644
--- a/clang/test/Parser/altivec.c
+++ b/clang/test/Parser/altivec.c
@@ -110,6 +110,20 @@ vector __bool long long v_bll4;  // expected-error 
{{use of 'long long' with
 #endif
 __vector long double  vv_ld3;// expected-error {{cannot use 'long 
double' with '__vector'}}
 vector long double  v_ld4;   // expected-error {{cannot use 'long 
double' with '__vector'}}
+vector float _Complex v_cf;  // expected-error {{cannot use '_Complex' 
with '__vector'}}
+vector double _Complex v_cd; // expected-error {{cannot use '_Complex' 
with '__vector'}}
+#ifndef __VSX__
+ // expected-error@-2 {{use of 'double' 
with '__vector' requires VSX support to be enabled (available on POWER7 or 
later)}}
+#endif
+vector long double _Complex v_cld;   // expected-error {{cannot use '_Complex' 
with '__vector'}}
+ // expected-error@-1 {{cannot use 'long 
double' with '__vector'}}
+__vector float _Complex v_cf2;   // expected-error {{cannot use '_Complex' 
with '__vector'}}
+__vector double _Complex v_cd2;  // expected-error {{cannot use '_Complex' 
with '__vector'}}
+#ifndef __VSX__
+ // expected-error@-2 {{use of 'double' 
with '__vector' requires VSX support to be enabled (available on POWER7 or 
later)}}
+#endif
+__vector long double _Complex v_cld2;// expected-error {{cannot use '_Complex' 
with '__vector'}}
+ // expected-error@-1 {{cannot use 'long 
double' with '__vector'}}
 vector bool float v_bf;  // expected-error {{cannot use 'float' 
with '__vector bool'}}
 vector bool double v_bd; // expected-error {{cannot use 'double' 
with '__vector bool'}}
 vector bool pixel v_bp;  // expected-error {{cannot use '__pixel' 
with '__vector bool'}}
diff --git a/clang/test/Parser/cxx-altivec.cpp 
b/clang/test/Parser/cxx-altivec.cpp
index 6da36663422b49..c071f333e2206f 100644
--- a/clang/test/Parser/cxx-altivec.cpp
+++ b/clang/test/Parser/cxx-altivec.cpp
@@ -111,6 +111,20 @@ vector __bool long long v_bll4;  // expected-error 
{{use of 'long long' with
 #endif
 __vector long double  vv_ld3;// expected-error {{cannot use 'long 
double' with '__vector'}}
 vector long double  v_ld4;   // expected-error {{cannot use 'long 
double' with '__vector'}}
+vector float _Complex v_cf;  // expected-error {{cannot use '_Complex' 
with '__vector'}}
+vector double _Complex v_cd; // expected-error {{cannot use '_Complex' 
with '__vector'}}
+#ifndef __VSX__
+ // expected-error@-2 {{use of 'double' 
with '__vector' 

[clang] [Clang][Sema] Do not accept "vector _Complex" for AltiVec/ZVector (PR #90467)

2024-04-29 Thread Ulrich Weigand via cfe-commits

https://github.com/uweigand created 
https://github.com/llvm/llvm-project/pull/90467

The AltiVec (POWER) and ZVector (IBM Z) language extensions do not support 
using the "vector" keyword when the element type is a complex type, but current 
code does not verify this.

Add a Sema check and diagnostic for this case.

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

>From ad881f8d30484088a960528df52cfbf5cbd9d210 Mon Sep 17 00:00:00 2001
From: Ulrich Weigand 
Date: Mon, 29 Apr 2024 15:04:31 +0200
Subject: [PATCH] [Clang][Sema] Do not accept "vector _Complex" for
 AltiVec/ZVector

The AltiVec (POWER) and ZVector (IBM Z) language extensions do
not support using the "vector" keyword when the element type is
a complex type, but current code does not verify this.

Add a Sema check and diagnostic for this case.

Fixes: https://github.com/llvm/llvm-project/issues/88399
---
 clang/include/clang/Basic/DiagnosticSemaKinds.td |  2 ++
 clang/lib/Sema/DeclSpec.cpp  |  4 
 clang/test/Parser/altivec.c  | 14 ++
 clang/test/Parser/cxx-altivec.cpp| 14 ++
 clang/test/Sema/zvector.c| 12 
 clang/test/Sema/zvector2.c   |  4 
 6 files changed, 50 insertions(+)

diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index fdca82934cb4dc..8853739969a4ca 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -307,6 +307,8 @@ def err_invalid_vector_long_long_decl_spec : Error <
   "POWER7 or later) to be enabled">;
 def err_invalid_vector_long_double_decl_spec : Error<
   "cannot use 'long double' with '__vector'">;
+def err_invalid_vector_complex_decl_spec : Error<
+  "cannot use '_Complex' with '__vector'">;
 def warn_vector_long_decl_spec_combination : Warning<
   "Use of 'long' with '__vector' is deprecated">, InGroup;
 
diff --git a/clang/lib/Sema/DeclSpec.cpp b/clang/lib/Sema/DeclSpec.cpp
index 5f63c857c43067..71225a7ed5ee62 100644
--- a/clang/lib/Sema/DeclSpec.cpp
+++ b/clang/lib/Sema/DeclSpec.cpp
@@ -1191,6 +1191,10 @@ void DeclSpec::Finish(Sema , const PrintingPolicy 
) {
 
   // Validate and finalize AltiVec vector declspec.
   if (TypeAltiVecVector) {
+// Complex vector types are not supported.
+if (TypeSpecComplex != TSC_unspecified)
+  S.Diag(TSCLoc, diag::err_invalid_vector_complex_decl_spec);
+
 // No vector long long without VSX (or ZVector).
 if ((getTypeSpecWidth() == TypeSpecifierWidth::LongLong) &&
 !S.Context.getTargetInfo().hasFeature("vsx") &&
diff --git a/clang/test/Parser/altivec.c b/clang/test/Parser/altivec.c
index daee5eae4d8430..f63a2bfa6abdc3 100644
--- a/clang/test/Parser/altivec.c
+++ b/clang/test/Parser/altivec.c
@@ -110,6 +110,20 @@ vector __bool long long v_bll4;  // expected-error 
{{use of 'long long' with
 #endif
 __vector long double  vv_ld3;// expected-error {{cannot use 'long 
double' with '__vector'}}
 vector long double  v_ld4;   // expected-error {{cannot use 'long 
double' with '__vector'}}
+vector float _Complex v_cf;  // expected-error {{cannot use '_Complex' 
with '__vector'}}
+vector double _Complex v_cd; // expected-error {{cannot use '_Complex' 
with '__vector'}}
+#ifndef __VSX__
+ // expected-error@-2 {{use of 'double' 
with '__vector' requires VSX support to be enabled (available on POWER7 or 
later)}}
+#endif
+vector long double _Complex v_cld;   // expected-error {{cannot use '_Complex' 
with '__vector'}}
+ // expected-error@-1 {{cannot use 'long 
double' with '__vector'}}
+__vector float _Complex v_cf2;   // expected-error {{cannot use '_Complex' 
with '__vector'}}
+__vector double _Complex v_cd2;  // expected-error {{cannot use '_Complex' 
with '__vector'}}
+#ifndef __VSX__
+ // expected-error@-2 {{use of 'double' 
with '__vector' requires VSX support to be enabled (available on POWER7 or 
later)}}
+#endif
+__vector long double _Complex v_cld2;// expected-error {{cannot use '_Complex' 
with '__vector'}}
+ // expected-error@-1 {{cannot use 'long 
double' with '__vector'}}
 vector bool float v_bf;  // expected-error {{cannot use 'float' 
with '__vector bool'}}
 vector bool double v_bd; // expected-error {{cannot use 'double' 
with '__vector bool'}}
 vector bool pixel v_bp;  // expected-error {{cannot use '__pixel' 
with '__vector bool'}}
diff --git a/clang/test/Parser/cxx-altivec.cpp 
b/clang/test/Parser/cxx-altivec.cpp
index 6da36663422b49..c071f333e2206f 100644
--- a/clang/test/Parser/cxx-altivec.cpp
+++ b/clang/test/Parser/cxx-altivec.cpp
@@ -111,6 +111,20 @@ vector __bool long long v_bll4;  // expected-error 
{{use of 'long long' with
 #endif
 __vector