aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNico Weber <nicolasweber@gmx.de>2012-09-26 08:19:01 +0000
committerNico Weber <nicolasweber@gmx.de>2012-09-26 08:19:01 +0000
commit93dec51750411678bb9c5bc1b27b259f5f5a23bd (patch)
treeaadf5413d552aee2e61b049e459e641f2689552c
parentc5e3df7d9951502fe016445f1c93dc9a3efea4df (diff)
Revert r163022, it caused PR13924.
Add a test for PR13924. Do not revert the test added in r163022, it surprisingly still passes even after reverting the code changes. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164672 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/Lex/Token.h3
-rw-r--r--lib/Lex/PPMacroExpansion.cpp6
-rw-r--r--lib/Lex/TokenLexer.cpp6
-rw-r--r--test/Preprocessor/microsoft-ext.c20
4 files changed, 21 insertions, 14 deletions
diff --git a/include/clang/Lex/Token.h b/include/clang/Lex/Token.h
index e422c67053..9c5a023f30 100644
--- a/include/clang/Lex/Token.h
+++ b/include/clang/Lex/Token.h
@@ -76,8 +76,7 @@ public:
DisableExpand = 0x04, // This identifier may never be macro expanded.
NeedsCleaning = 0x08, // Contained an escaped newline or trigraph.
LeadingEmptyMacro = 0x10, // Empty macro exists before this token.
- HasUDSuffix = 0x20, // This string or character literal has a ud-suffix.
- IgnoredComma = 0x40 // Flags ignored commas from nested macro expansions.
+ HasUDSuffix = 0x20 // This string or character literal has a ud-suffix.
};
tok::TokenKind getKind() const { return (tok::TokenKind)Kind; }
diff --git a/lib/Lex/PPMacroExpansion.cpp b/lib/Lex/PPMacroExpansion.cpp
index dcaa5a6636..1ef534daa7 100644
--- a/lib/Lex/PPMacroExpansion.cpp
+++ b/lib/Lex/PPMacroExpansion.cpp
@@ -419,11 +419,7 @@ MacroArgs *Preprocessor::ReadFunctionLikeMacroArgs(Token &MacroName,
}
} else if (Tok.is(tok::l_paren)) {
++NumParens;
- // In Microsoft-compatibility mode, commas from nested macro expan-
- // sions should not be considered as argument separators. We test
- // for this with the IgnoredComma token flag.
- } else if (Tok.is(tok::comma)
- && !(Tok.getFlags() & Token::IgnoredComma) && NumParens == 0) {
+ } else if (Tok.is(tok::comma) && NumParens == 0) {
// Comma ends this argument if there are more fixed arguments expected.
// However, if this is a variadic macro, and this is part of the
// variadic part, then the comma is just an argument token.
diff --git a/lib/Lex/TokenLexer.cpp b/lib/Lex/TokenLexer.cpp
index 379b5f3ec8..2e3e7c3721 100644
--- a/lib/Lex/TokenLexer.cpp
+++ b/lib/Lex/TokenLexer.cpp
@@ -225,12 +225,6 @@ void TokenLexer::ExpandFunctionArguments() {
Token &Tok = ResultToks[i];
if (Tok.is(tok::hashhash))
Tok.setKind(tok::unknown);
- // In Microsoft-compatibility mode, we follow MSVC's preprocessing
- // behaviour by not considering commas from nested macro expansions
- // as argument separators. Set a flag on the token so we can test
- // for this later when the macro expansion is processed.
- if (Tok.is(tok::comma) && PP.getLangOpts().MicrosoftMode)
- Tok.setFlag(Token::IgnoredComma);
}
if(ExpandLocStart.isValid()) {
diff --git a/test/Preprocessor/microsoft-ext.c b/test/Preprocessor/microsoft-ext.c
index 5046655b68..ec10374a1d 100644
--- a/test/Preprocessor/microsoft-ext.c
+++ b/test/Preprocessor/microsoft-ext.c
@@ -1,6 +1,24 @@
-// RUN: %clang_cc1 -E -fms-compatibility %s | FileCheck %s
+// RUN: %clang_cc1 -E -fms-compatibility %s -o %t
+// RUN: FileCheck %s < %t
# define M2(x, y) x + y
# define P(x, y) {x, y}
# define M(x, y) M2(x, P(x, y))
M(a, b) // CHECK: a + {a, b}
+
+// Regression test for PR13924
+#define GTEST_CONCAT_TOKEN_(foo, bar) GTEST_CONCAT_TOKEN_IMPL_(foo, bar)
+#define GTEST_CONCAT_TOKEN_IMPL_(foo, bar) foo ## bar
+
+#define GMOCK_INTERNAL_COUNT_AND_2_VALUE_PARAMS(p0, p1) P2
+
+#define GMOCK_ACTION_CLASS_(name, value_params)\
+ GTEST_CONCAT_TOKEN_(name##Action, GMOCK_INTERNAL_COUNT_##value_params)
+
+#define ACTION_TEMPLATE(name, template_params, value_params)\
+class GMOCK_ACTION_CLASS_(name, value_params) {\
+}
+
+ACTION_TEMPLATE(InvokeArgument,
+ HAS_1_TEMPLATE_PARAMS(int, k),
+ AND_2_VALUE_PARAMS(p0, p1));