mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-12-06 05:23:55 +00:00
Lex: Don't let annotation tokens get into macro expansion
We'd let annotation tokens from '#pragma pack' and the like get inside a function-like macro. This would lead to terror and mayhem; stop the madness early. This fixes PR22037. llvm-svn: 224896
This commit is contained in:
parent
a894e9e070
commit
f2d3bc0474
@ -332,7 +332,7 @@ def warn_cxx98_compat_variadic_macro : Warning<
|
||||
InGroup<CXX98CompatPedantic>, DefaultIgnore;
|
||||
def ext_named_variadic_macro : Extension<
|
||||
"named variadic macros are a GNU extension">, InGroup<VariadicMacros>;
|
||||
def err_embedded_include : Error<
|
||||
def err_embedded_directive : Error<
|
||||
"embedding a #%0 directive within macro arguments is not supported">;
|
||||
def ext_embedded_directive : Extension<
|
||||
"embedding a directive within macro arguments has undefined behavior">,
|
||||
|
@ -798,7 +798,8 @@ void Preprocessor::HandleDirective(Token &Result) {
|
||||
case tok::pp_import:
|
||||
case tok::pp_include_next:
|
||||
case tok::pp___include_macros:
|
||||
Diag(Result, diag::err_embedded_include) << II->getName();
|
||||
case tok::pp_pragma:
|
||||
Diag(Result, diag::err_embedded_directive) << II->getName();
|
||||
DiscardUntilEndOfDirective();
|
||||
return;
|
||||
default:
|
||||
|
@ -7,6 +7,11 @@ a(n =
|
||||
a);
|
||||
_Static_assert(n == 5, "");
|
||||
|
||||
#define M(A)
|
||||
M(
|
||||
#pragma pack(pop) // expected-error {{embedding a #pragma directive within macro arguments is not supported}}
|
||||
)
|
||||
|
||||
// header1.h
|
||||
void fail(const char *);
|
||||
#define MUNCH(...) \
|
||||
|
Loading…
Reference in New Issue
Block a user