[clang] 1260944 - [PowerPC][AIX] Make `__vector [un]signed long` an error
Hubert Tong via cfe-commits
cfe-commits at lists.llvm.org
Sun Oct 18 09:47:30 PDT 2020
Author: Hubert Tong
Date: 2020-10-18T12:39:16-04:00
New Revision: 126094485ab99dac3e6df9c201124d48a1d798ce
URL: https://github.com/llvm/llvm-project/commit/126094485ab99dac3e6df9c201124d48a1d798ce
DIFF: https://github.com/llvm/llvm-project/commit/126094485ab99dac3e6df9c201124d48a1d798ce.diff
LOG: [PowerPC][AIX] Make `__vector [un]signed long` an error
The semantics associated with `__vector [un]signed long` are neither
consistently specified nor consistently implemented.
The IBM XL compilers on AIX traditionally treated these as deprecated
aliases for the corresponding `__vector int` type in both 32-bit and
64-bit modes. The newer, Clang-based, IBM XL compilers on AIX make usage
of the previously deprecated types an error. This is also consistent
with IBM XL C/C++ for Linux on Power (on little endian distributions).
In line with the above, this patch upgrades (on AIX) the deprecation of
`__vector long` to become removal.
Reviewed By: ZarkoCA
Differential Revision: https://reviews.llvm.org/D89443
Added:
Modified:
clang/lib/Sema/DeclSpec.cpp
clang/test/Parser/altivec.c
clang/test/Parser/cxx-altivec.cpp
Removed:
################################################################################
diff --git a/clang/lib/Sema/DeclSpec.cpp b/clang/lib/Sema/DeclSpec.cpp
index a3f770bb00ad..dc37474db9fd 100644
--- a/clang/lib/Sema/DeclSpec.cpp
+++ b/clang/lib/Sema/DeclSpec.cpp
@@ -1196,7 +1196,13 @@ void DeclSpec::Finish(Sema &S, const PrintingPolicy &Policy) {
S.Diag(TSTLoc, diag::err_invalid_vector_float_decl_spec);
} else if (TypeSpecWidth == TSW_long) {
// vector long is unsupported for ZVector and deprecated for AltiVec.
- if (S.getLangOpts().ZVector)
+ // It has also been historically deprecated on AIX (as an alias for
+ // "vector int" in both 32-bit and 64-bit modes). It was then made
+ // unsupported in the Clang-based XL compiler since the deprecated type
+ // has a number of conflicting semantics and continuing to support it
+ // is a disservice to users.
+ if (S.getLangOpts().ZVector ||
+ S.Context.getTargetInfo().getTriple().isOSAIX())
S.Diag(TSWRange.getBegin(), diag::err_invalid_vector_long_decl_spec);
else
S.Diag(TSWRange.getBegin(),
diff --git a/clang/test/Parser/altivec.c b/clang/test/Parser/altivec.c
index 769b4dec98fc..e966679be54a 100644
--- a/clang/test/Parser/altivec.c
+++ b/clang/test/Parser/altivec.c
@@ -1,6 +1,8 @@
-// RUN: %clang_cc1 -triple=powerpc-apple-darwin8 -target-feature +altivec -fsyntax-only -verify %s
-// RUN: %clang_cc1 -triple=powerpc64-unknown-linux-gnu -target-feature +altivec -fsyntax-only -verify %s
-// RUN: %clang_cc1 -triple=powerpc64le-unknown-linux-gnu -target-feature +altivec -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple=powerpc-apple-darwin8 -target-feature +altivec -fsyntax-only -verify=expected,nonaix %s
+// RUN: %clang_cc1 -triple=powerpc64-unknown-linux-gnu -target-feature +altivec -fsyntax-only -verify=expected,nonaix %s
+// RUN: %clang_cc1 -triple=powerpc64le-unknown-linux-gnu -target-feature +altivec -fsyntax-only -verify=expected,nonaix %s
+// RUN: %clang_cc1 -triple=powerpc-ibm-aix -target-feature +altivec -fsyntax-only -verify=expected,aix %s
+// RUN: %clang_cc1 -triple=powerpc64-ibm-aix -target-feature +altivec -fsyntax-only -verify=expected,aix %s
__vector char vv_c;
__vector signed char vv_sc;
@@ -54,19 +56,33 @@ void f_a2(int b, vector int a);
vector int v = (vector int)(-1);
+// These should have errors on AIX and warnings otherwise.
+__vector long vv_l; // nonaix-warning {{Use of 'long' with '__vector' is deprecated}}
+ // aix-error at -1 {{cannot use 'long' with '__vector'}}
+__vector signed long vv_sl; // nonaix-warning {{Use of 'long' with '__vector' is deprecated}}
+ // aix-error at -1 {{cannot use 'long' with '__vector'}}
+__vector unsigned long vv_ul; // nonaix-warning {{Use of 'long' with '__vector' is deprecated}}
+ // aix-error at -1 {{cannot use 'long' with '__vector'}}
+__vector long int vv_li; // nonaix-warning {{Use of 'long' with '__vector' is deprecated}}
+ // aix-error at -1 {{cannot use 'long' with '__vector'}}
+__vector signed long int vv_sli; // nonaix-warning {{Use of 'long' with '__vector' is deprecated}}
+ // aix-error at -1 {{cannot use 'long' with '__vector'}}
+__vector unsigned long int vv_uli; // nonaix-warning {{Use of 'long' with '__vector' is deprecated}}
+ // aix-error at -1 {{cannot use 'long' with '__vector'}}
+vector long v_l; // nonaix-warning {{Use of 'long' with '__vector' is deprecated}}
+ // aix-error at -1 {{cannot use 'long' with '__vector'}}
+vector signed long v_sl; // nonaix-warning {{Use of 'long' with '__vector' is deprecated}}
+ // aix-error at -1 {{cannot use 'long' with '__vector'}}
+vector unsigned long v_ul; // nonaix-warning {{Use of 'long' with '__vector' is deprecated}}
+ // aix-error at -1 {{cannot use 'long' with '__vector'}}
+vector long int v_li; // nonaix-warning {{Use of 'long' with '__vector' is deprecated}}
+ // aix-error at -1 {{cannot use 'long' with '__vector'}}
+vector signed long int v_sli; // nonaix-warning {{Use of 'long' with '__vector' is deprecated}}
+ // aix-error at -1 {{cannot use 'long' with '__vector'}}
+vector unsigned long int v_uli; // nonaix-warning {{Use of 'long' with '__vector' is deprecated}}
+ // aix-error at -1 {{cannot use 'long' with '__vector'}}
+
// These should have warnings.
-__vector long vv_l; // expected-warning {{Use of 'long' with '__vector' is deprecated}}
-__vector signed long vv_sl; // expected-warning {{Use of 'long' with '__vector' is deprecated}}
-__vector unsigned long vv_ul; // expected-warning {{Use of 'long' with '__vector' is deprecated}}
-__vector long int vv_li; // expected-warning {{Use of 'long' with '__vector' is deprecated}}
-__vector signed long int vv_sli; // expected-warning {{Use of 'long' with '__vector' is deprecated}}
-__vector unsigned long int vv_uli; // expected-warning {{Use of 'long' with '__vector' is deprecated}}
-vector long v_l; // expected-warning {{Use of 'long' with '__vector' is deprecated}}
-vector signed long v_sl; // expected-warning {{Use of 'long' with '__vector' is deprecated}}
-vector unsigned long v_ul; // expected-warning {{Use of 'long' with '__vector' is deprecated}}
-vector long int v_li; // expected-warning {{Use of 'long' with '__vector' is deprecated}}
-vector signed long int v_sli; // expected-warning {{Use of 'long' with '__vector' is deprecated}}
-vector unsigned long int v_uli; // expected-warning {{Use of 'long' with '__vector' is deprecated}}
__vector long double vv_ld; // expected-error {{cannot use 'long double' with '__vector'}}
vector long double v_ld; // expected-error {{cannot use 'long double' with '__vector'}}
vector bool v_b; // expected-warning {{type specifier missing, defaults to 'int'}}
@@ -106,7 +122,7 @@ struct S {
// i8, i16, i32 here are field names, not type names.
vector bool i8; // expected-error {{requires a specifier or qualifier}}
vector pixel i16;
- vector long i32; // expected-warning {{deprecated}}
+ vector short i32;
};
void f() {
diff --git a/clang/test/Parser/cxx-altivec.cpp b/clang/test/Parser/cxx-altivec.cpp
index 6395452010d4..7fb3e93ce578 100644
--- a/clang/test/Parser/cxx-altivec.cpp
+++ b/clang/test/Parser/cxx-altivec.cpp
@@ -1,6 +1,8 @@
-// RUN: %clang_cc1 -triple=powerpc-apple-darwin8 -target-feature +altivec -fsyntax-only -verify -std=c++11 %s
-// RUN: %clang_cc1 -triple=powerpc64-unknown-linux-gnu -target-feature +altivec -fsyntax-only -verify -std=c++11 %s
-// RUN: %clang_cc1 -triple=powerpc64le-unknown-linux-gnu -target-feature +altivec -fsyntax-only -verify -std=c++11 %s
+// RUN: %clang_cc1 -triple=powerpc-apple-darwin8 -target-feature +altivec -fsyntax-only -verify=expected,nonaix -std=c++11 %s
+// RUN: %clang_cc1 -triple=powerpc64-unknown-linux-gnu -target-feature +altivec -fsyntax-only -verify=expected,nonaix -std=c++11 %s
+// RUN: %clang_cc1 -triple=powerpc64le-unknown-linux-gnu -target-feature +altivec -fsyntax-only -verify=expected,nonaix -std=c++11 %s
+// RUN: %clang_cc1 -triple=powerpc-ibm-aix -target-feature +altivec -fsyntax-only -verify=expected,aix -std=c++11 %s
+// RUN: %clang_cc1 -triple=powerpc64-ibm-aix -target-feature +altivec -fsyntax-only -verify=expected,aix -std=c++11 %s
#include <altivec.h>
__vector char vv_c;
@@ -55,19 +57,33 @@ void f_a2(int b, vector int a);
vector int v = (vector int)(-1);
+// These should have errors on AIX and warnings otherwise.
+__vector long vv_l; // nonaix-warning {{Use of 'long' with '__vector' is deprecated}}
+ // aix-error at -1 {{cannot use 'long' with '__vector'}}
+__vector signed long vv_sl; // nonaix-warning {{Use of 'long' with '__vector' is deprecated}}
+ // aix-error at -1 {{cannot use 'long' with '__vector'}}
+__vector unsigned long vv_ul; // nonaix-warning {{Use of 'long' with '__vector' is deprecated}}
+ // aix-error at -1 {{cannot use 'long' with '__vector'}}
+__vector long int vv_li; // nonaix-warning {{Use of 'long' with '__vector' is deprecated}}
+ // aix-error at -1 {{cannot use 'long' with '__vector'}}
+__vector signed long int vv_sli; // nonaix-warning {{Use of 'long' with '__vector' is deprecated}}
+ // aix-error at -1 {{cannot use 'long' with '__vector'}}
+__vector unsigned long int vv_uli; // nonaix-warning {{Use of 'long' with '__vector' is deprecated}}
+ // aix-error at -1 {{cannot use 'long' with '__vector'}}
+vector long v_l; // nonaix-warning {{Use of 'long' with '__vector' is deprecated}}
+ // aix-error at -1 {{cannot use 'long' with '__vector'}}
+vector signed long v_sl; // nonaix-warning {{Use of 'long' with '__vector' is deprecated}}
+ // aix-error at -1 {{cannot use 'long' with '__vector'}}
+vector unsigned long v_ul; // nonaix-warning {{Use of 'long' with '__vector' is deprecated}}
+ // aix-error at -1 {{cannot use 'long' with '__vector'}}
+vector long int v_li; // nonaix-warning {{Use of 'long' with '__vector' is deprecated}}
+ // aix-error at -1 {{cannot use 'long' with '__vector'}}
+vector signed long int v_sli; // nonaix-warning {{Use of 'long' with '__vector' is deprecated}}
+ // aix-error at -1 {{cannot use 'long' with '__vector'}}
+vector unsigned long int v_uli; // nonaix-warning {{Use of 'long' with '__vector' is deprecated}}
+ // aix-error at -1 {{cannot use 'long' with '__vector'}}
+
// These should have warnings.
-__vector long vv_l; // expected-warning {{Use of 'long' with '__vector' is deprecated}}
-__vector signed long vv_sl; // expected-warning {{Use of 'long' with '__vector' is deprecated}}
-__vector unsigned long vv_ul; // expected-warning {{Use of 'long' with '__vector' is deprecated}}
-__vector long int vv_li; // expected-warning {{Use of 'long' with '__vector' is deprecated}}
-__vector signed long int vv_sli; // expected-warning {{Use of 'long' with '__vector' is deprecated}}
-__vector unsigned long int vv_uli; // expected-warning {{Use of 'long' with '__vector' is deprecated}}
-vector long v_l; // expected-warning {{Use of 'long' with '__vector' is deprecated}}
-vector signed long v_sl; // expected-warning {{Use of 'long' with '__vector' is deprecated}}
-vector unsigned long v_ul; // expected-warning {{Use of 'long' with '__vector' is deprecated}}
-vector long int v_li; // expected-warning {{Use of 'long' with '__vector' is deprecated}}
-vector signed long int v_sli; // expected-warning {{Use of 'long' with '__vector' is deprecated}}
-vector unsigned long int v_uli; // expected-warning {{Use of 'long' with '__vector' is deprecated}}
__vector long double vv_ld; // expected-error {{cannot use 'long double' with '__vector'}}
vector long double v_ld; // expected-error {{cannot use 'long double' with '__vector'}}
More information about the cfe-commits
mailing list