diff options
-rw-r--r-- | clang/include/clang/Basic/DiagnosticSemaKinds.td | 1 | ||||
-rw-r--r-- | clang/lib/Sema/SemaDeclAttr.cpp | 3 | ||||
-rw-r--r-- | clang/test/SemaCUDA/alias.cu | 11 |
3 files changed, 15 insertions, 0 deletions
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 1ecddc1f4f5..e9e877eacf2 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -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 " diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index e0ce3adce42..b0a9a009f0f 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/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<FunctionDecl>(D)) { diff --git a/clang/test/SemaCUDA/alias.cu b/clang/test/SemaCUDA/alias.cu new file mode 100644 index 00000000000..39251ed10ec --- /dev/null +++ b/clang/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 |