]> granicus.if.org Git - clang/commitdiff
In assembler-with-cpp mode, don't error on '#' (stringize) operator applied to
authorDaniel Dunbar <daniel@zuster.org>
Fri, 22 May 2009 21:35:34 +0000 (21:35 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Fri, 22 May 2009 21:35:34 +0000 (21:35 +0000)
non-argument names, pass the tokens through.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72283 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Lex/PPDirectives.cpp
test/Preprocessor/assembler-with-cpp.c

index 331424bdc8e730a562bfc1848dd63a4551a106b2..d7b8fc7fd8242df1d2b3d120711d80abdd676976 100644 (file)
@@ -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);
         
index e27cf2d9704c877ca429237c330ca82bfb4ab7e5..885e67b98c8fdd172cf2c216ec76f62b300a2669 100644 (file)
@@ -29,6 +29,8 @@
 2: '
 3: "
 
+// (balance quotes to keep editors happy): "'
+
 // Empty char literals are ok.
 // RUN: grep "4: ''" %t &&
 4: ''
 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