summaryrefslogtreecommitdiffstats
path: root/libcpp/macro.c
diff options
context:
space:
mode:
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2005-04-05 20:07:06 +0000
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2005-04-05 20:07:06 +0000
commit99617355e9cba5fc47f5283caefbe0f22ef8c578 (patch)
tree304416eee80a3961e14c23478df57dbe2c47ef7f /libcpp/macro.c
parentcce7d16e8c6047c02f61bf8e7ab2a5b4cafd5fa0 (diff)
downloadppe42-gcc-99617355e9cba5fc47f5283caefbe0f22ef8c578.tar.gz
ppe42-gcc-99617355e9cba5fc47f5283caefbe0f22ef8c578.zip
PR preprocessor/19475
* macro.c (create_iso_definition): For < ISO C99, don't pedwarn if there is no whitespace between macro name and its replacement, but the replacement starts with a basic character set character. * gcc.dg/cpp/macspace1.c: New test. * gcc.dg/cpp/macspace2.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@97652 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libcpp/macro.c')
-rw-r--r--libcpp/macro.c35
1 files changed, 33 insertions, 2 deletions
diff --git a/libcpp/macro.c b/libcpp/macro.c
index 441b3b32ed3..daa2bd34a0e 100644
--- a/libcpp/macro.c
+++ b/libcpp/macro.c
@@ -1430,8 +1430,39 @@ create_iso_definition (cpp_reader *pfile, cpp_macro *macro)
macro->fun_like = 1;
}
else if (ctoken->type != CPP_EOF && !(ctoken->flags & PREV_WHITE))
- cpp_error (pfile, CPP_DL_PEDWARN,
- "ISO C requires whitespace after the macro name");
+ {
+ /* While ISO C99 requires whitespace before replacement text
+ in a macro definition, ISO C90 with TC1 allows there characters
+ from the basic source character set. */
+ if (CPP_OPTION (pfile, c99))
+ cpp_error (pfile, CPP_DL_PEDWARN,
+ "ISO C99 requires whitespace after the macro name");
+ else
+ {
+ int warntype = CPP_DL_WARNING;
+ switch (ctoken->type)
+ {
+ case CPP_ATSIGN:
+ case CPP_AT_NAME:
+ case CPP_OBJC_STRING:
+ /* '@' is not in basic character set. */
+ warntype = CPP_DL_PEDWARN;
+ break;
+ case CPP_OTHER:
+ /* Basic character set sans letters, digits and _. */
+ if (strchr ("!\"#%&'()*+,-./:;<=>?[\\]^{|}~",
+ ctoken->val.str.text[0]) == NULL)
+ warntype = CPP_DL_PEDWARN;
+ break;
+ default:
+ /* All other tokens start with a character from basic
+ character set. */
+ break;
+ }
+ cpp_error (pfile, warntype,
+ "missing whitespace after the macro name");
+ }
+ }
if (macro->fun_like)
token = lex_expansion_token (pfile, macro);
OpenPOWER on IntegriCloud