r258641 - [CUDA] Reject the alias attribute in CUDA device code.

Justin Lebar via cfe-commits cfe-commits at lists.llvm.org
Sat Jan 23 13:28:11 PST 2016


Author: jlebar
Date: Sat Jan 23 15:28:10 2016
New Revision: 258641

URL: http://llvm.org/viewvc/llvm-project?rev=258641&view=rev
Log:
[CUDA] Reject the alias attribute in CUDA device code.

Summary: CUDA (well, strictly speaking, NVPTX) doesn't support aliases.

Reviewers: echristo

Subscribers: cfe-commits, jhen, tra

Differential Revision: http://reviews.llvm.org/D16502

Added:
    cfe/trunk/test/SemaCUDA/alias.cu
Modified:
    cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
    cfe/trunk/lib/Sema/SemaDeclAttr.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=258641&r1=258640&r2=258641&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Sat Jan 23 15:28:10 2016
@@ -6425,6 +6425,7 @@ def warn_kern_is_inline : Warning<
   InGroup<CudaCompat>;
 def err_va_arg_in_device : Error<
   "CUDA device code does not support va_arg">;
+def err_alias_not_supported_on_nvptx : Error<"CUDA does not support aliases">;
 
 def warn_non_pod_vararg_with_format_string : Warning<
   "cannot pass %select{non-POD|non-trivial}0 object of type %1 to variadic "

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=258641&r1=258640&r2=258641&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Sat Jan 23 15:28:10 2016
@@ -1557,6 +1557,9 @@ static void handleAliasAttr(Sema &S, Dec
     S.Diag(Attr.getLoc(), diag::err_alias_not_supported_on_darwin);
     return;
   }
+  if (S.Context.getTargetInfo().getTriple().isNVPTX()) {
+    S.Diag(Attr.getLoc(), diag::err_alias_not_supported_on_nvptx);
+  }
 
   // Aliases should be on declarations, not definitions.
   if (const auto *FD = dyn_cast<FunctionDecl>(D)) {

Added: cfe/trunk/test/SemaCUDA/alias.cu
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCUDA/alias.cu?rev=258641&view=auto
==============================================================================
--- cfe/trunk/test/SemaCUDA/alias.cu (added)
+++ cfe/trunk/test/SemaCUDA/alias.cu Sat Jan 23 15:28:10 2016
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -triple nvptx-unknown-cuda -fsyntax-only -fcuda-is-device -verify -DEXPECT_ERR %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fsyntax-only -verify %s
+
+// The alias attribute is not allowed in CUDA device code.
+void bar();
+__attribute__((alias("bar"))) void foo();
+#ifdef EXPECT_ERR
+// expected-error at -2 {{CUDA does not support aliases}}
+#else
+// expected-no-diagnostics
+#endif




More information about the cfe-commits mailing list