From: Justin Lebar Date: Sat, 23 Jan 2016 21:28:10 +0000 (+0000) Subject: [CUDA] Reject the alias attribute in CUDA device code. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=937c06abd5e259157501073fd17b99e9bf28ded6;p=clang [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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@258641 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td index 1ecddc1f4f..e9e877eacf 100644 --- a/include/clang/Basic/DiagnosticSemaKinds.td +++ b/include/clang/Basic/DiagnosticSemaKinds.td @@ -6425,6 +6425,7 @@ def warn_kern_is_inline : Warning< InGroup; 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 " diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp index e0ce3adce4..b0a9a009f0 100644 --- a/lib/Sema/SemaDeclAttr.cpp +++ b/lib/Sema/SemaDeclAttr.cpp @@ -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(D)) { diff --git a/test/SemaCUDA/alias.cu b/test/SemaCUDA/alias.cu new file mode 100644 index 0000000000..39251ed10e --- /dev/null +++ b/test/SemaCUDA/alias.cu @@ -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