aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorNeil Booth <neil@daikokuya.demon.co.uk>2001-02-14 07:38:20 +0000
committerNeil Booth <neil@gcc.gnu.org>2001-02-14 07:38:20 +0000
commit7065e130e02c335c37f44874a83c4cbf59dfea89 (patch)
tree5dc2a18484a5feaa3e30f77dadcb35f5c4945fc5 /gcc
parent52682a1b7720c9f2d8528c3498631636f09ebd90 (diff)
downloadgcc-7065e130e02c335c37f44874a83c4cbf59dfea89.zip
gcc-7065e130e02c335c37f44874a83c4cbf59dfea89.tar.gz
gcc-7065e130e02c335c37f44874a83c4cbf59dfea89.tar.bz2
c-lex.c (lex_number): Only warn traditionally for U suffix outside system macros.
* c-lex.c (lex_number): Only warn traditionally for U suffix outside system macros. * cppexp.c (parse_number): Similarly. * cpplib.h (NODE_SYSHDR, cpp_sys_objmacro_p): New. * cppmacro.c (struct cpp_macro): New member node. (parse_args): Only warn about missing rest args if not a system macro. (funlike_invocation_p): Similarly for uninvoked funlike macros. (cpp_sys_objmacro_p): New. (_cpp_create_definition): Store the node with the macro defn. Remember if the macro is defined in a system header. From-SVN: r39661
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog14
-rw-r--r--gcc/c-lex.c9
-rw-r--r--gcc/cppexp.c4
-rw-r--r--gcc/cpplib.h1
-rw-r--r--gcc/cppmacro.c20
5 files changed, 42 insertions, 6 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 0de635f..2566f27 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,17 @@
+2001-02-14 Neil Booth <neil@daikokuya.demon.co.uk>
+
+ * c-lex.c (lex_number): Only warn traditionally for U suffix
+ outside system macros.
+ * cppexp.c (parse_number): Similarly.
+ * cpplib.h (NODE_SYSHDR, cpp_sys_objmacro_p): New.
+ * cppmacro.c (struct cpp_macro): New member node.
+ (parse_args): Only warn about missing rest args if not
+ a system macro.
+ (funlike_invocation_p): Similarly for uninvoked funlike macros.
+ (cpp_sys_objmacro_p): New.
+ (_cpp_create_definition): Store the node with the macro defn.
+ Remember if the macro is defined in a system header.
+
2001-02-13 DJ Delorie <dj@redhat.com>
* configure.in (check_languages): determine languages to check
diff --git a/gcc/c-lex.c b/gcc/c-lex.c
index 358e5d1..c147648 100644
--- a/gcc/c-lex.c
+++ b/gcc/c-lex.c
@@ -1225,7 +1225,8 @@ lex_number (str, len)
case 'f': case 'F':
if (fflag)
ERROR ("more than one 'f' suffix on floating constant");
- else if (warn_traditional && !in_system_header)
+ else if (warn_traditional && !in_system_header
+ && ! cpp_sys_objmacro_p (parse_in))
warning ("traditional C rejects the 'f' suffix");
fflag = 1;
@@ -1234,7 +1235,8 @@ lex_number (str, len)
case 'l': case 'L':
if (lflag)
ERROR ("more than one 'l' suffix on floating constant");
- else if (warn_traditional && !in_system_header)
+ else if (warn_traditional && !in_system_header
+ && ! cpp_sys_objmacro_p (parse_in))
warning ("traditional C rejects the 'l' suffix");
lflag = 1;
@@ -1309,7 +1311,8 @@ lex_number (str, len)
case 'u': case 'U':
if (spec_unsigned)
error ("two 'u' suffixes on integer constant");
- else if (warn_traditional && !in_system_header)
+ else if (warn_traditional && !in_system_header
+ && ! cpp_sys_objmacro_p (parse_in))
warning ("traditional C rejects the 'u' suffix");
spec_unsigned = 1;
diff --git a/gcc/cppexp.c b/gcc/cppexp.c
index 11cde70..6aa6d4b 100644
--- a/gcc/cppexp.c
+++ b/gcc/cppexp.c
@@ -203,7 +203,9 @@ parse_number (pfile, tok)
goto invalid_suffix;
op.unsignedp = sufftab[i].u;
- if (CPP_WTRADITIONAL (pfile) && sufftab[i].u)
+ if (CPP_WTRADITIONAL (pfile)
+ && sufftab[i].u
+ && ! cpp_sys_objmacro_p (pfile))
cpp_warning (pfile, "traditional C rejects the `U' suffix");
if (sufftab[i].l == 2 && CPP_OPTION (pfile, pedantic)
&& ! CPP_OPTION (pfile, c99))
diff --git a/gcc/cpplib.h b/gcc/cpplib.h
index eec4f1e..2b7a99d 100644
--- a/gcc/cpplib.h
+++ b/gcc/cpplib.h
@@ -604,6 +604,7 @@ extern void cpp_forall_identifiers PARAMS ((cpp_reader *,
extern void cpp_scan_buffer_nooutput PARAMS ((cpp_reader *, int));
extern void cpp_start_lookahead PARAMS ((cpp_reader *));
extern void cpp_stop_lookahead PARAMS ((cpp_reader *, int));
+extern int cpp_sys_objmacro_p PARAMS ((cpp_reader *));
/* In cppfiles.c */
extern int cpp_included PARAMS ((cpp_reader *, const char *));
diff --git a/gcc/cppmacro.c b/gcc/cppmacro.c
index 3b9f64c..7a65e97 100644
--- a/gcc/cppmacro.c
+++ b/gcc/cppmacro.c
@@ -44,6 +44,7 @@ struct cpp_macro
unsigned int fun_like : 1; /* If a function-like macro. */
unsigned int variadic : 1; /* If a variadic macro. */
unsigned int disabled : 1; /* If macro is disabled. */
+ unsigned int syshdr : 1; /* If macro defined in system header. */
};
typedef struct macro_arg macro_arg;
@@ -562,7 +563,7 @@ parse_args (pfile, node)
if (argc + 1 == macro->paramc && macro->variadic)
{
- if (CPP_PEDANTIC (pfile))
+ if (CPP_PEDANTIC (pfile) && ! macro->syshdr)
cpp_pedwarn (pfile, "ISO C99 requires rest arguments to be used");
}
else
@@ -616,7 +617,7 @@ funlike_invocation_p (pfile, node, list)
if (maybe_paren.type == CPP_OPEN_PAREN)
args = parse_args (pfile, node);
- else if (CPP_WTRADITIONAL (pfile))
+ else if (CPP_WTRADITIONAL (pfile) && ! node->value.macro->syshdr)
cpp_warning (pfile,
"function-like macro \"%s\" must be used with arguments in traditional C",
node->name);
@@ -995,6 +996,18 @@ cpp_get_token (pfile, token)
save_lookahead_token (pfile, token);
}
+/* Returns true if we're expanding an object-like macro that was
+ defined in a system header. Just checks the macro at the top of
+ the stack. Used for diagnostic suppression. */
+int
+cpp_sys_objmacro_p (pfile)
+ cpp_reader *pfile;
+{
+ cpp_macro *macro = pfile->context->macro;
+
+ return macro && ! macro->fun_like && macro->syshdr;
+}
+
/* Read each token in, until EOF. Directives are transparently
processed. */
void
@@ -1453,6 +1466,9 @@ _cpp_create_definition (pfile, node)
&& macro->expansion[0].type == CPP_NAME
&& macro->expansion[0].val.node == node);
+ /* To suppress some diagnostics. */
+ macro->syshdr = pfile->buffer->sysp != 0;
+
/* Commit the memory. */
POOL_COMMIT (&pfile->macro_pool, macro->count * sizeof (cpp_token));