unsigned ObjCExceptions : 1; // Support Objective-C exceptions.
unsigned CXXExceptions : 1; // Support C++ exceptions.
unsigned SjLjExceptions : 1; // Use setjmp-longjump exception handling.
+ unsigned TraditionalCPP : 1; /// Enable some traditional CPP emulation.
unsigned RTTI : 1; // Support RTTI information.
unsigned MSBitfields : 1; // MS-compatible structure layout
C99 = Microsoft = Borland = CPlusPlus = CPlusPlus0x = 0;
CXXOperatorNames = PascalStrings = WritableStrings = ConstStrings = 0;
Exceptions = ObjCExceptions = CXXExceptions = SjLjExceptions = 0;
- Freestanding = NoBuiltin = 0;
+ TraditionalCPP = Freestanding = NoBuiltin = 0;
MSBitfields = 0;
NeXTRuntime = 1;
RTTI = 1;
HelpText<"Store string literals as writable data">;
def fno_bitfield_type_align : Flag<"-fno-bitfield-type-align">,
HelpText<"Ignore bit-field types when aligning structures">;
+def traditional_cpp : Flag<"-traditional-cpp">,
+ HelpText<"Enable some traditional CPP emulation">;
//===----------------------------------------------------------------------===//
// Header Search Options
Res.push_back("-fcxx-exceptions");
if (Opts.SjLjExceptions)
Res.push_back("-fsjlj-exceptions");
+ if (Opts.TraditionalCPP)
+ Res.push_back("-traditional-cpp");
if (!Opts.RTTI)
Res.push_back("-fno-rtti");
if (Opts.MSBitfields)
Opts.ObjCExceptions = Args.hasArg(OPT_fobjc_exceptions);
Opts.CXXExceptions = Args.hasArg(OPT_fcxx_exceptions);
Opts.SjLjExceptions = Args.hasArg(OPT_fsjlj_exceptions);
+ Opts.TraditionalCPP = Args.hasArg(OPT_traditional_cpp);
Opts.RTTI = !Args.hasArg(OPT_fno_rtti);
Opts.Blocks = Args.hasArg(OPT_fblocks);
// If the next token is obviously a // or /* */ comment, skip it efficiently
// too (without going through the big switch stmt).
if (CurPtr[0] == '/' && CurPtr[1] == '/' && !inKeepCommentMode() &&
- Features.BCPLComment) {
+ Features.BCPLComment && !Features.TraditionalCPP) {
if (SkipBCPLComment(Result, CurPtr+2))
return; // There is a token to return.
goto SkipIgnoredUnits;
// this as "foo / bar" and langauges with BCPL comments would lex it as
// "foo". Check to see if the character after the second slash is a '*'.
// If so, we will lex that as a "/" instead of the start of a comment.
- if (Features.BCPLComment ||
- getCharAndSize(CurPtr+SizeTmp, SizeTmp2) != '*') {
+ // However, we never do this in -traditional-cpp mode.
+ if ((Features.BCPLComment ||
+ getCharAndSize(CurPtr+SizeTmp, SizeTmp2) != '*') &&
+ !Features.TraditionalCPP) {
if (SkipBCPLComment(Result, ConsumeChar(CurPtr, SizeTmp, Result)))
return; // There is a token to return.
--- /dev/null
+/* Clang supports a very limited subset of -traditional-cpp, basically we only
+ * intend to add support for things that people actually rely on when doing
+ * things like using /usr/bin/cpp to preprocess non-source files. */
+
+/*
+ RUN: %clang_cc1 -traditional-cpp %s -E -o %t
+ RUN: FileCheck < %t %s
+*/
+
+/* CHECK: foo // bar
+ */
+foo // bar