Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CUDA] Disallow variable-length arrays in CUDA device code.
Reviewers: tra Subscribers: cfe-commits, jhen Differential Revision: https://reviews.llvm.org/D25050 llvm-svn: 282647
- Loading branch information
Justin Lebar
committed
Sep 28, 2016
1 parent
2a8db34
commit b17840d
Showing
6 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// RUN: %clang_cc1 -fcuda-is-device -verify -S %s -o /dev/null | ||
// RUN: %clang_cc1 -verify -DHOST %s -S -o /dev/null | ||
|
||
#include "Inputs/cuda.h" | ||
|
||
#ifdef HOST | ||
// expected-no-diagnostics | ||
#endif | ||
|
||
__host__ __device__ void hd(int n) { | ||
int x[n]; | ||
#ifndef HOST | ||
// expected-error@-2 {{cannot use variable-length arrays in __host__ __device__ functions}} | ||
#endif | ||
} | ||
|
||
// No error because never codegen'ed for device. | ||
__host__ __device__ inline void hd_inline(int n) { | ||
int x[n]; | ||
} | ||
void call_hd_inline() { hd_inline(42); } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// RUN: %clang_cc1 -fcuda-is-device -fsyntax-only -verify %s | ||
// RUN: %clang_cc1 -fsyntax-only -verify -DHOST %s | ||
|
||
#include "Inputs/cuda.h" | ||
|
||
void host(int n) { | ||
int x[n]; | ||
} | ||
|
||
__device__ void device(int n) { | ||
int x[n]; // expected-error {{cannot use variable-length arrays in __device__ functions}} | ||
} |