[PATCH] D16502: [CUDA] Reject the alias attribute in CUDA device code.
Eric Christopher via cfe-commits
cfe-commits at lists.llvm.org
Sat Jan 23 11:37:52 PST 2016
OK.
-eric
On Fri, Jan 22, 2016 at 5:56 PM Justin Lebar <jlebar at google.com> wrote:
> jlebar created this revision.
> jlebar added a reviewer: tra.
> jlebar added subscribers: echristo, jhen, cfe-commits.
>
> CUDA (well, strictly speaking, NVPTX) doesn't support aliases.
>
> http://reviews.llvm.org/D16502
>
> Files:
> include/clang/Basic/DiagnosticSemaKinds.td
> lib/Sema/SemaDeclAttr.cpp
> test/SemaCUDA/alias.cu
>
> Index: test/SemaCUDA/alias.cu
> ===================================================================
> --- /dev/null
> +++ test/SemaCUDA/alias.cu
> @@ -0,0 +1,14 @@
> +// REQUIRES: x86-registered-target
> +// REQUIRES: nvptx-registered-target
> +// 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
> Index: lib/Sema/SemaDeclAttr.cpp
> ===================================================================
> --- lib/Sema/SemaDeclAttr.cpp
> +++ lib/Sema/SemaDeclAttr.cpp
> @@ -1557,6 +1557,9 @@
> 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)) {
> Index: include/clang/Basic/DiagnosticSemaKinds.td
> ===================================================================
> --- include/clang/Basic/DiagnosticSemaKinds.td
> +++ include/clang/Basic/DiagnosticSemaKinds.td
> @@ -6427,6 +6427,7 @@
> "CUDA device code does not support variadic functions">;
> 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 "
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160123/3069b921/attachment-0001.html>
More information about the cfe-commits
mailing list