]> granicus.if.org Git - clang/commitdiff
[CUDA] Reject the alias attribute in CUDA device code.
authorJustin Lebar <jlebar@google.com>
Sat, 23 Jan 2016 21:28:10 +0000 (21:28 +0000)
committerJustin Lebar <jlebar@google.com>
Sat, 23 Jan 2016 21:28:10 +0000 (21:28 +0000)
Summary: CUDA (well, strictly speaking, NVPTX) doesn't support aliases.

Reviewers: echristo

Subscribers: cfe-commits, jhen, tra

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@258641 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/DiagnosticSemaKinds.td
lib/Sema/SemaDeclAttr.cpp
test/SemaCUDA/alias.cu [new file with mode: 0644]

index 1ecddc1f4f5e0623f169c7d700f33303b992c143..e9e877eacf204c64af28c9ae76e178632e61ae14 100644 (file)
@@ -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 "
index e0ce3adce4243c2d38f2338b2318aad1a1911b06..b0a9a009f0ff5642a3fce4f10fd27bcd86e5d2cf 100644 (file)
@@ -1557,6 +1557,9 @@ static void handleAliasAttr(Sema &S, Decl *D, const AttributeList &Attr) {
     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)) {
diff --git a/test/SemaCUDA/alias.cu b/test/SemaCUDA/alias.cu
new file mode 100644 (file)
index 0000000..39251ed
--- /dev/null
@@ -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@-2 {{CUDA does not support aliases}}
+#else
+// expected-no-diagnostics
+#endif