[clang] [SYCL] do not support any SYCL standard except 2020 (PR #120258)

via cfe-commits cfe-commits at lists.llvm.org
Tue Dec 17 08:41:06 PST 2024


https://github.com/dklochkov-emb updated https://github.com/llvm/llvm-project/pull/120258

>From 00b7797fb0e7095d398cb8a46f8ed3f9714989e2 Mon Sep 17 00:00:00 2001
From: "Klochkov, Denis" <denis.klochkov at intel.com>
Date: Tue, 17 Dec 2024 16:49:55 +0100
Subject: [PATCH] [SYCL] do not support any SYCL standard except 2020

[SYCL] fix formatting

[SYCL] remove spaces
---
 clang/include/clang/Basic/LangOptions.h       |  1 -
 clang/include/clang/Driver/Options.td         |  4 +--
 clang/lib/Frontend/InitPreprocessor.cpp       |  4 +--
 clang/test/Preprocessor/sycl-macro.cpp        |  3 ---
 .../Frontend/CompilerInvocationTest.cpp       | 26 +++++++++----------
 5 files changed, 16 insertions(+), 22 deletions(-)

diff --git a/clang/include/clang/Basic/LangOptions.h b/clang/include/clang/Basic/LangOptions.h
index 949c8f5d448bcf..6e1117da7adeb6 100644
--- a/clang/include/clang/Basic/LangOptions.h
+++ b/clang/include/clang/Basic/LangOptions.h
@@ -148,7 +148,6 @@ class LangOptionsBase {
 
   enum SYCLMajorVersion {
     SYCL_None,
-    SYCL_2017,
     SYCL_2020,
     // The "default" SYCL version to be used when none is specified on the
     // frontend command line.
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index 88862ae9edb29d..8493ff98d23047 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -8346,8 +8346,8 @@ def sycl_std_EQ : Joined<["-"], "sycl-std=">, Group<sycl_Group>,
   Flags<[NoArgumentUnused]>,
   Visibility<[ClangOption, CC1Option, CLOption]>,
   HelpText<"SYCL language standard to compile for.">,
-  Values<"2020,2017,121,1.2.1,sycl-1.2.1">,
-  NormalizedValues<["SYCL_2020", "SYCL_2017", "SYCL_2017", "SYCL_2017", "SYCL_2017"]>,
+  Values<"2020">,
+  NormalizedValues<["SYCL_2020"]>,
   NormalizedValuesScope<"LangOptions">,
   MarshallingInfoEnum<LangOpts<"SYCLVersion">, "SYCL_None">,
   ShouldParseIf<!strconcat(fsycl_is_device.KeyPath, "||", fsycl_is_host.KeyPath)>;
diff --git a/clang/lib/Frontend/InitPreprocessor.cpp b/clang/lib/Frontend/InitPreprocessor.cpp
index e20feedb840b51..6aa71cb0ee10d5 100644
--- a/clang/lib/Frontend/InitPreprocessor.cpp
+++ b/clang/lib/Frontend/InitPreprocessor.cpp
@@ -584,9 +584,7 @@ static void InitializeStandardPredefinedMacros(const TargetInfo &TI,
 
   if (LangOpts.SYCLIsDevice || LangOpts.SYCLIsHost) {
     // SYCL Version is set to a value when building SYCL applications
-    if (LangOpts.getSYCLVersion() == LangOptions::SYCL_2017)
-      Builder.defineMacro("CL_SYCL_LANGUAGE_VERSION", "121");
-    else if (LangOpts.getSYCLVersion() == LangOptions::SYCL_2020)
+    if (LangOpts.getSYCLVersion() == LangOptions::SYCL_2020)
       Builder.defineMacro("SYCL_LANGUAGE_VERSION", "202012L");
   }
 
diff --git a/clang/test/Preprocessor/sycl-macro.cpp b/clang/test/Preprocessor/sycl-macro.cpp
index a509086f99e413..23228d326575b9 100644
--- a/clang/test/Preprocessor/sycl-macro.cpp
+++ b/clang/test/Preprocessor/sycl-macro.cpp
@@ -1,9 +1,6 @@
 // RUN: %clang_cc1 %s -E -dM | FileCheck %s
-// RUN: %clang_cc1 %s -fsycl-is-device -sycl-std=2017 -E -dM | FileCheck --check-prefix=CHECK-SYCL-STD %s
-// RUN: %clang_cc1 %s -fsycl-is-host -sycl-std=2017 -E -dM | FileCheck --check-prefix=CHECK-SYCL-STD %s
 // RUN: %clang_cc1 %s -fsycl-is-host -sycl-std=2020 -E -dM | FileCheck --check-prefix=CHECK-SYCL-STD-2020 %s
 // RUN: %clang_cc1 %s -fsycl-is-host -E -dM | FileCheck --check-prefix=CHECK-SYCL-STD-2020 %s
-// RUN: %clang_cc1 %s -fsycl-is-device -sycl-std=1.2.1 -E -dM | FileCheck --check-prefix=CHECK-SYCL-STD %s
 // RUN: %clang_cc1 %s -fsycl-is-device -sycl-std=2020 -E -dM | FileCheck --check-prefix=CHECK-SYCL-STD-2020 %s
 // RUN: %clang_cc1 %s -fsycl-is-device -E -dM | FileCheck --check-prefixes=CHECK-SYCL %s
 
diff --git a/clang/unittests/Frontend/CompilerInvocationTest.cpp b/clang/unittests/Frontend/CompilerInvocationTest.cpp
index 94ab9fe8451e0a..8461b623881d91 100644
--- a/clang/unittests/Frontend/CompilerInvocationTest.cpp
+++ b/clang/unittests/Frontend/CompilerInvocationTest.cpp
@@ -603,7 +603,7 @@ TEST_F(CommandLineTest, ConditionalParsingIfFalseFlagNotPresent) {
 }
 
 TEST_F(CommandLineTest, ConditionalParsingIfFalseFlagPresent) {
-  const char *Args[] = {"-sycl-std=2017"};
+  const char *Args[] = {"-sycl-std=2020"};
 
   CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
 
@@ -641,16 +641,16 @@ TEST_F(CommandLineTest, ConditionalParsingIfOddSyclStdArg1) {
 
   CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
 
-  ASSERT_FALSE(Diags->hasErrorOccurred());
+  ASSERT_TRUE(Diags->hasErrorOccurred());
   ASSERT_TRUE(Invocation.getLangOpts().SYCLIsDevice);
   ASSERT_FALSE(Invocation.getLangOpts().SYCLIsHost);
-  ASSERT_EQ(Invocation.getLangOpts().getSYCLVersion(), LangOptions::SYCL_2017);
+  ASSERT_EQ(Invocation.getLangOpts().getSYCLVersion(), LangOptions::SYCL_None);
 
   Invocation.generateCC1CommandLine(GeneratedArgs, *this);
 
   ASSERT_THAT(GeneratedArgs, Contains(StrEq("-fsycl-is-device")));
   ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("-fsycl-is-host"))));
-  ASSERT_THAT(GeneratedArgs, Contains(HasSubstr("-sycl-std=2017")));
+  ASSERT_THAT(GeneratedArgs, Not(Contains(HasSubstr("-sycl-std=2020"))));
 }
 
 TEST_F(CommandLineTest, ConditionalParsingIfOddSyclStdArg2) {
@@ -658,16 +658,16 @@ TEST_F(CommandLineTest, ConditionalParsingIfOddSyclStdArg2) {
 
   CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
 
-  ASSERT_FALSE(Diags->hasErrorOccurred());
+  ASSERT_TRUE(Diags->hasErrorOccurred());
   ASSERT_TRUE(Invocation.getLangOpts().SYCLIsDevice);
   ASSERT_FALSE(Invocation.getLangOpts().SYCLIsHost);
-  ASSERT_EQ(Invocation.getLangOpts().getSYCLVersion(), LangOptions::SYCL_2017);
+  ASSERT_EQ(Invocation.getLangOpts().getSYCLVersion(), LangOptions::SYCL_None);
 
   Invocation.generateCC1CommandLine(GeneratedArgs, *this);
 
   ASSERT_THAT(GeneratedArgs, Contains(StrEq("-fsycl-is-device")));
   ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("-fsycl-is-host"))));
-  ASSERT_THAT(GeneratedArgs, Contains(HasSubstr("-sycl-std=2017")));
+  ASSERT_THAT(GeneratedArgs, Not(Contains(HasSubstr("-sycl-std=2020"))));
 }
 
 TEST_F(CommandLineTest, ConditionalParsingIfOddSyclStdArg3) {
@@ -675,16 +675,16 @@ TEST_F(CommandLineTest, ConditionalParsingIfOddSyclStdArg3) {
 
   CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
 
-  ASSERT_FALSE(Diags->hasErrorOccurred());
+  ASSERT_TRUE(Diags->hasErrorOccurred());
   ASSERT_TRUE(Invocation.getLangOpts().SYCLIsDevice);
   ASSERT_FALSE(Invocation.getLangOpts().SYCLIsHost);
-  ASSERT_EQ(Invocation.getLangOpts().getSYCLVersion(), LangOptions::SYCL_2017);
+  ASSERT_EQ(Invocation.getLangOpts().getSYCLVersion(), LangOptions::SYCL_None);
 
   Invocation.generateCC1CommandLine(GeneratedArgs, *this);
 
   ASSERT_THAT(GeneratedArgs, Contains(StrEq("-fsycl-is-device")));
   ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("-fsycl-is-host"))));
-  ASSERT_THAT(GeneratedArgs, Contains(HasSubstr("-sycl-std=2017")));
+  ASSERT_THAT(GeneratedArgs, Not(Contains(HasSubstr("-sycl-std=2020"))));
 }
 
 TEST_F(CommandLineTest, ConditionalParsingIfTrueFlagNotPresentHost) {
@@ -718,17 +718,17 @@ TEST_F(CommandLineTest, ConditionalParsingIfTrueFlagNotPresentDevice) {
 }
 
 TEST_F(CommandLineTest, ConditionalParsingIfTrueFlagPresent) {
-  const char *Args[] = {"-fsycl-is-device", "-sycl-std=2017"};
+  const char *Args[] = {"-fsycl-is-device", "-sycl-std=2020"};
 
   CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
 
   ASSERT_FALSE(Diags->hasErrorOccurred());
-  ASSERT_EQ(Invocation.getLangOpts().getSYCLVersion(), LangOptions::SYCL_2017);
+  ASSERT_EQ(Invocation.getLangOpts().getSYCLVersion(), LangOptions::SYCL_2020);
 
   Invocation.generateCC1CommandLine(GeneratedArgs, *this);
 
   ASSERT_THAT(GeneratedArgs, Contains(StrEq("-fsycl-is-device")));
-  ASSERT_THAT(GeneratedArgs, Contains(StrEq("-sycl-std=2017")));
+  ASSERT_THAT(GeneratedArgs, Contains(StrEq("-sycl-std=2020")));
 }
 
 // Wide integer option.



More information about the cfe-commits mailing list