diff options
author | Jakub Jelinek <jakub@redhat.com> | 2005-04-05 22:07:06 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2005-04-05 22:07:06 +0200 |
commit | cae064e7982fb1a9f7e2fd8208e83199786aa39c (patch) | |
tree | 304416eee80a3961e14c23478df57dbe2c47ef7f /libcpp | |
parent | 87ac6a500a79d67ce4ef3cd0980eedf195ad33d0 (diff) | |
download | gcc-cae064e7982fb1a9f7e2fd8208e83199786aa39c.zip gcc-cae064e7982fb1a9f7e2fd8208e83199786aa39c.tar.gz gcc-cae064e7982fb1a9f7e2fd8208e83199786aa39c.tar.bz2 |
re PR preprocessor/19475 (missing whitespace after macro name in C90 or C++)
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.
From-SVN: r97652
Diffstat (limited to 'libcpp')
-rw-r--r-- | libcpp/ChangeLog | 8 | ||||
-rw-r--r-- | libcpp/macro.c | 35 |
2 files changed, 41 insertions, 2 deletions
diff --git a/libcpp/ChangeLog b/libcpp/ChangeLog index 99476d0..48b24ec 100644 --- a/libcpp/ChangeLog +++ b/libcpp/ChangeLog @@ -1,3 +1,11 @@ +2005-04-05 Jakub Jelinek <jakub@redhat.com> + + 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. + 2005-03-28 Andreas Jaeger <aj@suse.de> * lex.c (warn_about_normalization): Cast field width to int to diff --git a/libcpp/macro.c b/libcpp/macro.c index 441b3b3..daa2bd3 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); |