Skip to content

Commit f7e87dd

Browse files
committed
[CUDA][HIP] Change default lang std to c++14
Currently clang and nvcc use c++14 as default std for C++. gcc 11 even uses c++17 as default std for C++. However, clang uses c++98 as default std for CUDA/HIP. As c++14 has been well adopted and became default for clang, it seems reasonable to use c++14 as default std for CUDA/HIP. Reviewed by: Artem Belevich Differential Revision: https://reviews.llvm.org/D103221
1 parent 5fc9653 commit f7e87dd

File tree

7 files changed

+24
-16
lines changed

7 files changed

+24
-16
lines changed

‎clang/include/clang/Basic/LangStandards.def‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,11 +194,11 @@ LANGSTANDARD_ALIAS_DEPR(openclcpp, "CLC++")
194194

195195
// CUDA
196196
LANGSTANDARD(cuda, "cuda", CUDA, "NVIDIA CUDA(tm)",
197-
LineComment | CPlusPlus | Digraphs)
197+
LineComment | CPlusPlus | CPlusPlus11 | CPlusPlus14 | Digraphs)
198198

199199
// HIP
200200
LANGSTANDARD(hip, "hip", HIP, "HIP",
201-
LineComment | CPlusPlus | Digraphs)
201+
LineComment | CPlusPlus | CPlusPlus11 | CPlusPlus14 | Digraphs)
202202

203203
#undef LANGSTANDARD
204204
#undef LANGSTANDARD_ALIAS

‎clang/test/Parser/cuda-kernel-call.cu‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ void foo(void) {
1212
1313
// The following two are parse errors because -std=c++11 is not enabled.
1414
15-
S<S<S<int>>> s; // expected-error 2{{use '> >'}}
16-
S<S<S<>>> s1; // expected-error 2{{use '> >'}}
17-
(void)(&f<S<S<int>>>==0); // expected-error 2{{use '> >'}}
18-
(void)(&f<S<S<>>>==0); // expected-error 2{{use '> >'}}
15+
S<S<S<int>>> s;
16+
S<S<S<>>> s1;
17+
(void)(&f<S<S<int>>>==0);
18+
(void)(&f<S<S<>>>==0);
1919
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// RUN: %clang_cc1 -dM -E -x hip %s | FileCheck -check-prefix=CXX14 %s
2+
// RUN: %clang_cc1 -dM -E %s | FileCheck -check-prefix=CXX14 %s
3+
// RUN: %clang_cc1 -dM -E -std=c++98 -x hip %s | FileCheck -check-prefix=CXX98 %s
4+
// RUN: %clang_cc1 -dM -E -std=c++98 %s | FileCheck -check-prefix=CXX98 %s
5+
6+
// CXX98: #define __cplusplus 199711L
7+
// CXX14: #define __cplusplus 201402L

‎clang/test/SemaCUDA/asm_delayed_diags.cu‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ static __device__ __host__ unsigned t2(signed char input) {
2828
}
2929

3030
static __device__ __host__ double t3(double x) {
31-
register long double result;
31+
long double result;
3232
__asm __volatile("frndint"
3333
: "=t"(result)
3434
: "0"(x));

‎clang/test/SemaCUDA/cuda-builtin-vars.cu‎

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
// RUN: %clang_cc1 "-triple" "nvptx-nvidia-cuda" -fcuda-is-device -fsyntax-only -verify %s
1+
// RUN: %clang_cc1 "-triple" "nvptx-nvidia-cuda" -fcuda-is-device -fsyntax-only -verify \
2+
// RUN: -verify-ignore-unexpected=note %s
23

34
#include "__clang_cuda_builtin_vars.h"
45
__attribute__((global))
@@ -37,17 +38,13 @@ void kernel(int *out) {
3738
// expected-note@__clang_cuda_builtin_vars.h:* {{variable 'warpSize' declared const here}}
3839

3940
// Make sure we can't construct or assign to the special variables.
40-
__cuda_builtin_threadIdx_t x; // expected-error {{calling a private constructor of class '__cuda_builtin_threadIdx_t'}}
41-
// expected-note@__clang_cuda_builtin_vars.h:* {{declared private here}}
41+
__cuda_builtin_threadIdx_t x; // expected-error {{call to deleted constructor of '__cuda_builtin_threadIdx_t'}}
4242

43-
__cuda_builtin_threadIdx_t y = threadIdx; // expected-error {{calling a private constructor of class '__cuda_builtin_threadIdx_t'}}
44-
// expected-note@__clang_cuda_builtin_vars.h:* {{declared private here}}
43+
__cuda_builtin_threadIdx_t y = threadIdx; // expected-error {{call to deleted constructor of '__cuda_builtin_threadIdx_t'}}
4544

46-
threadIdx = threadIdx; // expected-error {{'operator=' is a private member of '__cuda_builtin_threadIdx_t'}}
47-
// expected-note@__clang_cuda_builtin_vars.h:* {{declared private here}}
45+
threadIdx = threadIdx; // expected-error {{overload resolution selected deleted operator '='}}
4846

49-
void *ptr = &threadIdx; // expected-error {{'operator&' is a private member of '__cuda_builtin_threadIdx_t'}}
50-
// expected-note@__clang_cuda_builtin_vars.h:* {{declared private here}}
47+
void *ptr = &threadIdx; // expected-error {{overload resolution selected deleted operator '&'}}
5148

5249
// Following line should've caused an error as one is not allowed to
5350
// take address of a built-in variable in CUDA. Alas there's no way

‎clang/test/SemaCUDA/function-target.cu‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ __host__ __device__ void h1hd(void);
99
__global__ void h1g(void);
1010

1111
struct h1ds { // expected-note {{requires 1 argument}}
12+
// expected-note@-1 {{candidate constructor (the implicit move constructor) not viable}}
1213
__device__ h1ds(); // expected-note {{candidate constructor not viable: call to __device__ function from __host__ function}}
1314
};
1415

‎clang/test/SemaCUDA/implicit-member-target-collision.cu‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ struct C1_with_collision : A1_with_host_ctor, B1_with_device_ctor {
1919
// expected-note@-3 {{candidate constructor (the implicit default constructor}} not viable
2020
// expected-note@-4 {{implicit default constructor inferred target collision: call to both __host__ and __device__ members}}
2121
// expected-note@-5 {{candidate constructor (the implicit copy constructor}} not viable
22+
// expected-note@-6 {{candidate constructor (the implicit move constructor) not viable}}
2223

2324
void hostfoo1() {
2425
C1_with_collision c; // expected-error {{no matching constructor}}
@@ -35,6 +36,7 @@ struct C2_with_collision {
3536
// expected-note@-5 {{candidate constructor (the implicit default constructor}} not viable
3637
// expected-note@-6 {{implicit default constructor inferred target collision: call to both __host__ and __device__ members}}
3738
// expected-note@-7 {{candidate constructor (the implicit copy constructor}} not viable
39+
// expected-note@-8 {{candidate constructor (the implicit move constructor) not viable}}
3840

3941
void hostfoo2() {
4042
C2_with_collision c; // expected-error {{no matching constructor}}
@@ -51,6 +53,7 @@ struct C3_with_collision : A1_with_host_ctor {
5153
// expected-note@-4 {{candidate constructor (the implicit default constructor}} not viable
5254
// expected-note@-5 {{implicit default constructor inferred target collision: call to both __host__ and __device__ members}}
5355
// expected-note@-6 {{candidate constructor (the implicit copy constructor}} not viable
56+
// expected-note@-7 {{candidate constructor (the implicit move constructor) not viable}}
5457

5558
void hostfoo3() {
5659
C3_with_collision c; // expected-error {{no matching constructor}}

0 commit comments

Comments
 (0)