Index: include/clang/Basic/DiagnosticParseKinds.td =================================================================== --- include/clang/Basic/DiagnosticParseKinds.td +++ include/clang/Basic/DiagnosticParseKinds.td @@ -972,6 +972,8 @@ "OpenCL extension %0 is core feature or supported optional core feature - ignoring">, InGroup>, DefaultIgnore; // OpenCL errors. +def err_opencl_address_of_label : Error< + "OpenCL does not support address of label ('&&') GNU extension">; def err_opencl_taking_function_address_parser : Error< "taking address of function is not allowed">; def err_opencl_logical_exclusive_or : Error< Index: lib/Parse/ParseExpr.cpp =================================================================== --- lib/Parse/ParseExpr.cpp +++ lib/Parse/ParseExpr.cpp @@ -1104,6 +1104,9 @@ if (Tok.isNot(tok::identifier)) return ExprError(Diag(Tok, diag::err_expected) << tok::identifier); + if (getLangOpts().OpenCL) + return ExprError(Diag(Tok, diag::err_opencl_address_of_label)); + if (getCurScope()->getFnParent() == nullptr) return ExprError(Diag(Tok, diag::err_address_of_label_outside_fn)); Index: test/SemaOpenCL/ampamp-gnu.cl =================================================================== --- /dev/null +++ test/SemaOpenCL/ampamp-gnu.cl @@ -0,0 +1,10 @@ +// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only + +kernel void foo(global int *in) { + int a; + void *p = &&a; // expected-error {{OpenCL does not support address of label ('&&') GNU extension}} + + void *hlbl_tbl[] = { &&label1 }; // expected-error {{OpenCL does not support address of label ('&&') GNU extension}} +label1: + a = 0; +}