"too few arguments provided to function-like macro invocation">;
def err_pp_bad_paste : Error<
"pasting formed '%0', an invalid preprocessing token">;
+def err_pp_bad_paste_ms : Warning<
+ "pasting formed '%0', an invalid preprocessing token">, DefaultError,
+ InGroup<DiagGroup<"invalid-token-paste">>;
def err_pp_operator_used_as_macro_name : Error<
"C++ operator '%0' cannot be used as a macro name">;
def err_pp_illegal_floating_literal : Error<
return true;
}
- // Do not emit the warning when preprocessing assembler code.
+ // Do not emit the error when preprocessing assembler code.
if (!PP.getLangOptions().AsmPreprocessor) {
// Explicitly convert the token location to have proper instantiation
// information so that the user knows where it came from.
SourceLocation Loc =
SM.createInstantiationLoc(PasteOpLoc, InstantiateLocStart,
InstantiateLocEnd, 2);
- PP.Diag(Loc, diag::err_pp_bad_paste)
+ // If we're in microsoft extensions mode, downgrade this from a hard
+ // error to a warning that defaults to an error. This allows
+ // disabling it.
+ PP.Diag(Loc,
+ PP.getLangOptions().Microsoft ? diag::err_pp_bad_paste_ms
+ : diag::err_pp_bad_paste)
<< std::string(Buffer.begin(), Buffer.end());
}
// RUN: %clang_cc1 -P -E -fms-extensions %s | FileCheck -strict-whitespace %s
+
// This horrible stuff should preprocess into (other than whitespace):
// int foo;
// int bar;
// CHECK: int baz
// CHECK: ;
+
+// rdar://8197149 - VC++ allows invalid token pastes: (##baz
+#define foo(x) abc(x)
+#define bar(y) foo(##baz(y))
+bar(q)
+
+// CHECK: abc(baz(q))