Index: include/clang/Basic/DiagnosticLexKinds.td =================================================================== --- include/clang/Basic/DiagnosticLexKinds.td +++ include/clang/Basic/DiagnosticLexKinds.td @@ -393,8 +393,8 @@ def note_macro_here : Note<"macro %0 defined here">; def note_macro_expansion_here : Note<"expansion of macro %0 requested here">; -def err_pp_opencl_variadic_macros : - Error<"variadic macros not supported in OpenCL">; +def ext_pp_opencl_variadic_macros : Extension< + "variadic macros are a Clang extension in OpenCL">; def err_pp_invalid_directive : Error<"invalid preprocessing directive">; def err_pp_directive_required : Error< Index: lib/Lex/PPDirectives.cpp =================================================================== --- lib/Lex/PPDirectives.cpp +++ lib/Lex/PPDirectives.cpp @@ -2235,8 +2235,7 @@ // OpenCL v1.2 s6.9.e: variadic macros are not supported. if (LangOpts.OpenCL) { - Diag(Tok, diag::err_pp_opencl_variadic_macros); - return true; + Diag(Tok, diag::ext_pp_opencl_variadic_macros); } // Lex the token after the identifier. Index: test/Misc/warning-flags.c =================================================================== --- test/Misc/warning-flags.c +++ test/Misc/warning-flags.c @@ -96,4 +96,4 @@ The list of warnings in -Wpedantic should NEVER grow. -CHECK: Number in -Wpedantic (not covered by other -W flags): 27 +CHECK: Number in -Wpedantic (not covered by other -W flags): 28 Index: test/Preprocessor/macro_variadic.cl =================================================================== --- test/Preprocessor/macro_variadic.cl +++ test/Preprocessor/macro_variadic.cl @@ -1,3 +1,20 @@ -// RUN: %clang_cc1 -verify %s +// RUN: %clang_cc1 -verify %s -cl-std=CL1.2 +// RUN: %clang_cc1 -verify %s -pedantic -DPEDANTIC -cl-std=CL1.2 -#define X(...) 1 // expected-error {{variadic macros not supported in OpenCL}} + +#define NO_VAR_FUNC(...) 5 +#define VAR_FUNC(...) func(__VA_ARGS__); +#define VAR_PRINTF(str, ...) printf(str, __VA_ARGS__); +#ifdef PEDANTIC +// expected-warning@-4{{variadic macros are a Clang extension in OpenCL}} +// expected-warning@-4{{variadic macros are a Clang extension in OpenCL}} +// expected-warning@-4{{variadic macros are a Clang extension in OpenCL}} +#endif + +int printf(__constant const char *st, ...); + +void foo() { + NO_VAR_FUNC(1, 2, 3); + VAR_FUNC(1, 2, 3); //expected-error{{implicit declaration of function 'func' is invalid in OpenCL}} + VAR_PRINTF("%i", 1); +}