public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-8553] c-family: Add <time.h> names to diagnostics for known headers
@ 2022-07-06 20:35 Jonathan Wakely
0 siblings, 0 replies; only message in thread
From: Jonathan Wakely @ 2022-07-06 20:35 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:40ddc305802cb7174e5b3d2e9b31e783b46f3769
commit r12-8553-g40ddc305802cb7174e5b3d2e9b31e783b46f3769
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Wed Jun 29 23:41:46 2022 +0100
c-family: Add <time.h> names to diagnostics for known headers
gcc/c-family/ChangeLog:
* known-headers.cc (get_stdlib_header_for_name): Add <time.h>
names.
gcc/testsuite/ChangeLog:
* g++.dg/spellcheck-stdlib.C: Check <ctime> types and functions.
(cherry picked from commit d489ec082ea214109ff54071410f8cd00344e654)
Diff:
---
| 14 ++++++++++++++
gcc/testsuite/g++.dg/spellcheck-stdlib.C | 29 +++++++++++++++++++++++++++++
2 files changed, 43 insertions(+)
--git a/gcc/c-family/known-headers.cc b/gcc/c-family/known-headers.cc
index 8ad3eb3f466..1c08f2c09d7 100644
--- a/gcc/c-family/known-headers.cc
+++ b/gcc/c-family/known-headers.cc
@@ -200,6 +200,20 @@ get_stdlib_header_for_name (const char *name, enum stdlib lib)
{"WINT_MAX", {"<stdint.h>", "<cstdint>"} },
{"WINT_MIN", {"<stdint.h>", "<cstdint>"} },
+ /* <time.h>. */
+ {"asctime", {"<time.h>", "<ctime>"} },
+ {"clock", {"<time.h>", "<ctime>"} },
+ {"clock_t", {"<time.h>", "<ctime>"} },
+ {"ctime", {"<time.h>", "<ctime>"} },
+ {"difftime", {"<time.h>", "<ctime>"} },
+ {"gmtime", {"<time.h>", "<ctime>"} },
+ {"localtime", {"<time.h>", "<ctime>"} },
+ {"mktime", {"<time.h>", "<ctime>"} },
+ {"strftime", {"<time.h>", "<ctime>"} },
+ {"time", {"<time.h>", "<ctime>"} },
+ {"time_t", {"<time.h>", "<ctime>"} },
+ {"tm", {"<time.h>", "<ctime>"} },
+
/* <wchar.h>. */
{"WCHAR_MAX", {"<wchar.h>", "<cwchar>"} },
{"WCHAR_MIN", {"<wchar.h>", "<cwchar>"} }
diff --git a/gcc/testsuite/g++.dg/spellcheck-stdlib.C b/gcc/testsuite/g++.dg/spellcheck-stdlib.C
index 87736b25e54..7a70641e3ae 100644
--- a/gcc/testsuite/g++.dg/spellcheck-stdlib.C
+++ b/gcc/testsuite/g++.dg/spellcheck-stdlib.C
@@ -158,6 +158,35 @@ void test_cstdlib (void *q)
// { dg-message "'#include <cstdlib>'" "" { target *-*-* } .-1 }
}
+/* Missing <ctime>. */
+
+void test_ctime (void *q, long s, double d)
+{
+ clock_t c; // { dg-error "was not declared" }
+ // { dg-message "'#include <ctime>'" "" { target *-*-* } .-1 }
+ time_t t; // { dg-error "was not declared" }
+ // { dg-message "'#include <ctime>'" "" { target *-*-* } .-1 }
+ tm t2; // { dg-error "was not declared" }
+ // { dg-message "'#include <ctime>'" "" { target *-*-* } .-1 }
+ d = difftime (0, 0); // { dg-error "was not declared" }
+ // { dg-message "'#include <ctime>'" "" { target *-*-* } .-1 }
+ s = mktime (q); // { dg-error "was not declared" }
+ // { dg-message "'#include <ctime>'" "" { target *-*-* } .-1 }
+ s = time (0); // { dg-error "was not declared" }
+ // { dg-message "'#include <ctime>'" "" { target *-*-* } .-1 }
+ q = asctime (0); // { dg-error "was not declared" }
+ // { dg-message "'#include <ctime>'" "" { target *-*-* } .-1 }
+ q = ctime (0); // { dg-error "was not declared" }
+ // { dg-message "'#include <ctime>'" "" { target *-*-* } .-1 }
+ q = gmtime (0); // { dg-error "was not declared" }
+ // { dg-message "'#include <ctime>'" "" { target *-*-* } .-1 }
+ q = localtime (0); // { dg-error "was not declared" }
+ // { dg-message "'#include <ctime>'" "" { target *-*-* } .-1 }
+ char c[2];
+ strftime (c, 2, "", 0); // { dg-error "was not declared" }
+ // { dg-message "'#include <ctime>'" "" { target *-*-* } .-1 }
+}
+
/* Verify that we don't offer suggestions to stdlib globals names when
there's an explicit namespace. */
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-07-06 20:35 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-06 20:35 [gcc r12-8553] c-family: Add <time.h> names to diagnostics for known headers Jonathan Wakely
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).