mirror of https://github.com/microsoft/clang.git
[OpenCL] Produce an error, instead of a warning, for sizeof(void) in OpenCL.
Patch by joey.gouly@arm.com git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@198264 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
28010ae796
commit
f1c0e48372
|
@ -4243,6 +4243,8 @@ def ext_sizeof_alignof_function_type : Extension<
|
|||
def ext_sizeof_alignof_void_type : Extension<
|
||||
"invalid application of '%select{sizeof|alignof|vec_step}0' to a void "
|
||||
"type">, InGroup<PointerArith>;
|
||||
def err_opencl_sizeof_alignof_type : Error<
|
||||
"invalid application of '%select{sizeof|alignof|vec_step}0' to a void type">;
|
||||
def err_sizeof_alignof_incomplete_type : Error<
|
||||
"invalid application of '%select{sizeof|alignof|vec_step}0' to an "
|
||||
"incomplete type %1">;
|
||||
|
|
|
@ -3244,9 +3244,12 @@ static bool CheckExtensionTraitOperandType(Sema &S, QualType T,
|
|||
return false;
|
||||
}
|
||||
|
||||
// Allow sizeof(void)/alignof(void) as an extension.
|
||||
// Allow sizeof(void)/alignof(void) as an extension, unless in OpenCL where
|
||||
// this is an error (OpenCL v1.1 s6.3.k)
|
||||
if (T->isVoidType()) {
|
||||
S.Diag(Loc, diag::ext_sizeof_alignof_void_type) << TraitKind << ArgRange;
|
||||
unsigned DiagID = S.LangOpts.OpenCL ? diag::err_opencl_sizeof_alignof_type
|
||||
: diag::ext_sizeof_alignof_void_type;
|
||||
S.Diag(Loc, DiagID) << TraitKind << ArgRange;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
// RUN: %clang_cc1 %s -verify -fsyntax-only
|
||||
|
||||
kernel void test(global int* buf) {
|
||||
buf[0] = sizeof(void); // expected-error {{invalid application of 'sizeof' to a void type}}
|
||||
}
|
Loading…
Reference in New Issue