aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Lex/PPDirectives.cpp8
-rw-r--r--test/Preprocessor/assembler-with-cpp.c10
2 files changed, 15 insertions, 3 deletions
diff --git a/lib/Lex/PPDirectives.cpp b/lib/Lex/PPDirectives.cpp
index 331424bdc8..d7b8fc7fd8 100644
--- a/lib/Lex/PPDirectives.cpp
+++ b/lib/Lex/PPDirectives.cpp
@@ -1376,9 +1376,11 @@ void Preprocessor::HandleDefineDirective(Token &DefineTok) {
// Get the next token of the macro.
LexUnexpandedToken(Tok);
- // Not a macro arg identifier?
- if (!Tok.getIdentifierInfo() ||
- MI->getArgumentNum(Tok.getIdentifierInfo()) == -1) {
+ // Check for a valid macro arg identifier, unless this is a .S file in
+ // which case it is still added to the body.
+ if ((!Tok.getIdentifierInfo() ||
+ MI->getArgumentNum(Tok.getIdentifierInfo()) == -1) &&
+ !getLangOptions().AsmPreprocessor) {
Diag(Tok, diag::err_pp_stringize_not_parameter);
ReleaseMacroInfo(MI);
diff --git a/test/Preprocessor/assembler-with-cpp.c b/test/Preprocessor/assembler-with-cpp.c
index e27cf2d970..885e67b98c 100644
--- a/test/Preprocessor/assembler-with-cpp.c
+++ b/test/Preprocessor/assembler-with-cpp.c
@@ -29,6 +29,8 @@
2: '
3: "
+// (balance quotes to keep editors happy): "'
+
// Empty char literals are ok.
// RUN: grep "4: ''" %t &&
4: ''
@@ -53,4 +55,12 @@
7: FOO(blarg)
+//
+#define T6() T6 #nostring
+#define T7(x) T7 #x
+T6()
+T7(foo)
+// RUN: grep 'T6 #nostring' %t &&
+// RUN: grep 'T7 "foo"' %t &&
+
// RUN: true