[clang] 443f490 - Revert "[CUDA][HIP] Use the same default language std as C++"
Sylvestre Ledru via cfe-commits
cfe-commits at lists.llvm.org
Thu Jul 20 01:55:04 PDT 2023
Author: Sylvestre Ledru
Date: 2023-07-20T10:54:54+02:00
New Revision: 443f490b6aac4af28500f4b09b68a13260f4fba9
URL: https://github.com/llvm/llvm-project/commit/443f490b6aac4af28500f4b09b68a13260f4fba9
DIFF: https://github.com/llvm/llvm-project/commit/443f490b6aac4af28500f4b09b68a13260f4fba9.diff
LOG: Revert "[CUDA][HIP] Use the same default language std as C++"
This reverts commit 2d1d07152bd26b001dedec3400b4b01d3bb11622.
Added:
Modified:
clang/docs/ReleaseNotes.rst
clang/include/clang/Basic/LangStandards.def
clang/lib/Basic/LangStandards.cpp
clang/test/CodeGenCUDA/long-double.cu
clang/test/Driver/unknown-std.cpp
clang/test/Preprocessor/lang-std.cpp
Removed:
################################################################################
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index ef1cc898c21f6d..2287ff9d70da3f 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -886,9 +886,6 @@ RISC-V Support
CUDA/HIP Language Changes
^^^^^^^^^^^^^^^^^^^^^^^^^
-- Clang has been updated to align its default language standard for CUDA/HIP with
- that of C++. The standard has now been enhanced to gnu++17, supplanting the
- previously used c++14.
CUDA Support
^^^^^^^^^^^^
diff --git a/clang/include/clang/Basic/LangStandards.def b/clang/include/clang/Basic/LangStandards.def
index 5c28bdd28ef257..911b626e4c9661 100644
--- a/clang/include/clang/Basic/LangStandards.def
+++ b/clang/include/clang/Basic/LangStandards.def
@@ -214,6 +214,14 @@ LANGSTANDARD_ALIAS_DEPR(openclcpp10, "CLC++")
LANGSTANDARD_ALIAS_DEPR(openclcpp10, "CLC++1.0")
LANGSTANDARD_ALIAS_DEPR(openclcpp2021, "CLC++2021")
+// CUDA
+LANGSTANDARD(cuda, "cuda", CUDA, "NVIDIA CUDA(tm)",
+ LineComment | CPlusPlus | CPlusPlus11 | CPlusPlus14 | Digraphs)
+
+// HIP
+LANGSTANDARD(hip, "hip", HIP, "HIP",
+ LineComment | CPlusPlus | CPlusPlus11 | CPlusPlus14 | Digraphs)
+
// HLSL
LANGSTANDARD(hlsl, "hlsl",
HLSL, "High Level Shader Language",
diff --git a/clang/lib/Basic/LangStandards.cpp b/clang/lib/Basic/LangStandards.cpp
index 033c0efe8d4f5d..c6a1a0acc2cb7e 100644
--- a/clang/lib/Basic/LangStandards.cpp
+++ b/clang/lib/Basic/LangStandards.cpp
@@ -54,6 +54,8 @@ LangStandard::Kind clang::getDefaultLanguageStandard(clang::Language Lang,
return LangStandard::lang_opencl12;
case Language::OpenCLCXX:
return LangStandard::lang_openclcpp10;
+ case Language::CUDA:
+ return LangStandard::lang_cuda;
case Language::Asm:
case Language::C:
// The PS4 uses C99 as the default C standard.
@@ -64,13 +66,13 @@ LangStandard::Kind clang::getDefaultLanguageStandard(clang::Language Lang,
return LangStandard::lang_gnu11;
case Language::CXX:
case Language::ObjCXX:
- case Language::CUDA:
- case Language::HIP:
if (T.isPS())
return LangStandard::lang_gnucxx14;
return LangStandard::lang_gnucxx17;
case Language::RenderScript:
return LangStandard::lang_c99;
+ case Language::HIP:
+ return LangStandard::lang_hip;
case Language::HLSL:
return LangStandard::lang_hlsl2021;
}
diff --git a/clang/test/CodeGenCUDA/long-double.cu b/clang/test/CodeGenCUDA/long-double.cu
index d52de972ea3da4..454a93ce5f6b6a 100644
--- a/clang/test/CodeGenCUDA/long-double.cu
+++ b/clang/test/CodeGenCUDA/long-double.cu
@@ -6,7 +6,7 @@
// RUN: -aux-triple x86_64-unknown-gnu-linux -fcuda-is-device \
// RUN: -emit-llvm -o - %s 2>&1 | FileCheck %s
-// CHECK: @_ZN15infinity_helperIeE5valueE = {{.*}} double 0x47EFFFFFD586B834,{{.*}} align 8
+// CHECK: @_ZN15infinity_helperIeE5valueE = {{.*}} double 0x47EFFFFFD586B834, align 8
// CHECK: @size = {{.*}} i32 8
#include "Inputs/cuda.h"
diff --git a/clang/test/Driver/unknown-std.cpp b/clang/test/Driver/unknown-std.cpp
index 5c58042a0a2c71..e918c087095ef0 100644
--- a/clang/test/Driver/unknown-std.cpp
+++ b/clang/test/Driver/unknown-std.cpp
@@ -4,10 +4,7 @@
// RUN: not %clang %s -std=foobar -c 2>&1 | FileCheck --match-full-lines %s
// RUN: not %clang -x objective-c++ %s -std=foobar -c 2>&1 | FileCheck --match-full-lines %s
-// RUN: not %clang -x cuda -nocudainc -nocudalib --cuda-path=%S/Inputs/CUDA/usr/local/cuda \
-// RUN: %s -std=foobar -c 2>&1 | FileCheck --match-full-lines %s
-// RUN: not %clang -x hip -nocudainc -nocudalib %s -std=foobar -c 2>&1 \
-// RUN: | FileCheck --match-full-lines %s
+// RUN: not %clang -x cuda -nocudainc -nocudalib --cuda-path=%S/Inputs/CUDA/usr/local/cuda %s -std=foobar -c 2>&1 | FileCheck --match-full-lines --check-prefix=CHECK --check-prefix=CUDA %s
// CHECK: error: invalid value 'foobar' in '-std=foobar'
// CHECK-NEXT: note: use 'c++98' or 'c++03' for 'ISO C++ 1998 with amendments' standard
@@ -24,6 +21,7 @@
// CHECK-NEXT: note: use 'gnu++23' for 'ISO C++ 2023 DIS with GNU extensions' standard
// CHECK-NEXT: note: use 'c++2c' or 'c++26' for 'Working draft for C++2c' standard
// CHECK-NEXT: note: use 'gnu++2c' or 'gnu++26' for 'Working draft for C++2c with GNU extensions' standard
+// CUDA-NEXT: note: use 'cuda' for 'NVIDIA CUDA(tm)' standard
// Make sure that no other output is present.
// CHECK-NOT: {{^.+$}}
diff --git a/clang/test/Preprocessor/lang-std.cpp b/clang/test/Preprocessor/lang-std.cpp
index 1fb0759679e04f..881d38641bc73c 100644
--- a/clang/test/Preprocessor/lang-std.cpp
+++ b/clang/test/Preprocessor/lang-std.cpp
@@ -1,14 +1,12 @@
+// UNSUPPORTED: target={{.*-(ps4|ps5)}}
/// Test default standards.
-/// CUDA/HIP uses the same default standards as C++.
+/// PS4/PS5 default to gnu++14.
-// RUN: %clang_cc1 -dM -E %s | grep __cplusplus >%T-cpp-std.txt
-// RUN: %clang_cc1 -dM -E -x cuda %s | grep __cplusplus >%T-cuda-cuda.txt
-// RUN: %clang_cc1 -dM -E -x hip %s | grep __cplusplus >%T-hip-std.txt
-// RUN:
diff %T-cpp-std.txt %T-cuda-cuda.txt
-// RUN:
diff %T-cpp-std.txt %T-hip-std.txt
+// RUN: %clang_cc1 -dM -E %s | FileCheck --check-prefix=CXX17 %s
+// RUN: %clang_cc1 -dM -E -x cuda %s | FileCheck --check-prefix=CXX14 %s
+// RUN: %clang_cc1 -dM -E -x hip %s | FileCheck --check-prefix=CXX14 %s
// RUN: %clang_cc1 -dM -E -x cuda -std=c++14 %s | FileCheck --check-prefix=CXX14 %s
-// RUN: %clang_cc1 -dM -E -x cuda -std=c++17 %s | FileCheck --check-prefix=CXX17 %s
// RUN: %clang_cc1 -dM -E -x hip -std=c++98 %s | FileCheck --check-prefix=CXX98 %s
// CXX98: #define __cplusplus 199711L
More information about the cfe-commits
mailing list