diff options
Diffstat (limited to 'gcc/testsuite/gcc.dg/cpp')
31 files changed, 215 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/cpp/warn-comments-2.c b/gcc/testsuite/gcc.dg/cpp/warn-comments-2.c new file mode 100644 index 00000000000..5a17f2bdcf2 --- /dev/null +++ b/gcc/testsuite/gcc.dg/cpp/warn-comments-2.c @@ -0,0 +1,7 @@ +// { dg-do preprocess } +// { dg-options "-std=gnu99 -fdiagnostics-show-option -Werror=comments" } + +/* /* */ // { dg-error "\"\.\*\" within comment .-Wcomments." } + +// \ + // { dg-error "multi-line comment .-Wcomments." "multi-line" { target *-*-* } 6 } diff --git a/gcc/testsuite/gcc.dg/cpp/warn-comments.c b/gcc/testsuite/gcc.dg/cpp/warn-comments.c new file mode 100644 index 00000000000..6f3d5a56fa7 --- /dev/null +++ b/gcc/testsuite/gcc.dg/cpp/warn-comments.c @@ -0,0 +1,7 @@ +// { dg-do preprocess } +// { dg-options "-std=gnu99 -fdiagnostics-show-option -Wcomments" } + +/* /* */ // { dg-warning "\"\.\*\" within comment .-Wcomments." } + +// \ + // { dg-warning "multi-line comment .-Wcomments." "multi-line" { target *-*-* } 6 } diff --git a/gcc/testsuite/gcc.dg/cpp/warn-cxx-compat-2.c b/gcc/testsuite/gcc.dg/cpp/warn-cxx-compat-2.c new file mode 100644 index 00000000000..6bf7d555e14 --- /dev/null +++ b/gcc/testsuite/gcc.dg/cpp/warn-cxx-compat-2.c @@ -0,0 +1,4 @@ +// { dg-do preprocess } +// { dg-options "-std=gnu99 -fdiagnostics-show-option -Werror=c++-compat" } + +#define not ! // { dg-error "identifier \"not\" is a special operator name in C\\+\\+ .-Wc\\+\\+-compat." } diff --git a/gcc/testsuite/gcc.dg/cpp/warn-cxx-compat.c b/gcc/testsuite/gcc.dg/cpp/warn-cxx-compat.c new file mode 100644 index 00000000000..2e7b2593235 --- /dev/null +++ b/gcc/testsuite/gcc.dg/cpp/warn-cxx-compat.c @@ -0,0 +1,4 @@ +// { dg-do preprocess } +// { dg-options "-std=gnu99 -fdiagnostics-show-option -Wc++-compat" } + +#define not ! // { dg-warning "identifier \"not\" is a special operator name in C\\+\\+ .-Wc\\+\\+-compat." } diff --git a/gcc/testsuite/gcc.dg/cpp/warn-deprecated-2.c b/gcc/testsuite/gcc.dg/cpp/warn-deprecated-2.c new file mode 100644 index 00000000000..b9cfffb9630 --- /dev/null +++ b/gcc/testsuite/gcc.dg/cpp/warn-deprecated-2.c @@ -0,0 +1,7 @@ +// { dg-do preprocess } +// { dg-options "-std=gnu99 -fdiagnostics-show-option -Werror=deprecated" } + +#assert x(x) // { dg-error "#assert is a deprecated GCC extension .-Wdeprecated." } + +#if #x(x) // { dg-error "assertions are a deprecated extension .-Wdeprecated." } +#endif diff --git a/gcc/testsuite/gcc.dg/cpp/warn-deprecated.c b/gcc/testsuite/gcc.dg/cpp/warn-deprecated.c new file mode 100644 index 00000000000..84214b1f8db --- /dev/null +++ b/gcc/testsuite/gcc.dg/cpp/warn-deprecated.c @@ -0,0 +1,7 @@ +// { dg-do preprocess } +// { dg-options "-std=gnu99 -fdiagnostics-show-option -Wdeprecated" } + +#assert x(x) // { dg-warning "#assert is a deprecated GCC extension .-Wdeprecated." } + +#if #x(x) // { dg-warning "assertions are a deprecated extension .-Wdeprecated." } +#endif diff --git a/gcc/testsuite/gcc.dg/cpp/warn-long-long-2.c b/gcc/testsuite/gcc.dg/cpp/warn-long-long-2.c new file mode 100644 index 00000000000..11eb5fb2666 --- /dev/null +++ b/gcc/testsuite/gcc.dg/cpp/warn-long-long-2.c @@ -0,0 +1,6 @@ +// { dg-do preprocess } +// { dg-options "-std=gnu99 -fdiagnostics-show-option -Wtraditional -Werror=long-long" } + +#if 0LL // { dg-error "traditional C rejects the \"LL\" suffix .-Wlong-long." } + // { dg-error "use of C99 long long integer constant .-Wlong-long." "use long long" { target *-*-* } 4 } +#endif diff --git a/gcc/testsuite/gcc.dg/cpp/warn-long-long.c b/gcc/testsuite/gcc.dg/cpp/warn-long-long.c new file mode 100644 index 00000000000..e86f9a6288d --- /dev/null +++ b/gcc/testsuite/gcc.dg/cpp/warn-long-long.c @@ -0,0 +1,6 @@ +// { dg-do preprocess } +// { dg-options "-std=gnu99 -fdiagnostics-show-option -Wtraditional -Wlong-long" } + +#if 0LL // { dg-warning "traditional C rejects the \"LL\" suffix .-Wlong-long." } + // { dg-warning "use of C99 long long integer constant .-Wlong-long." "use long long" { target *-*-* } 4 } +#endif diff --git a/gcc/testsuite/gcc.dg/cpp/warn-multichar-2.c b/gcc/testsuite/gcc.dg/cpp/warn-multichar-2.c new file mode 100644 index 00000000000..31d33bb9bb8 --- /dev/null +++ b/gcc/testsuite/gcc.dg/cpp/warn-multichar-2.c @@ -0,0 +1,5 @@ +// { dg-do preprocess } +// { dg-options "-std=gnu99 -fdiagnostics-show-option -Werror=multichar" } + +#if 'abc' // { dg-error "multi-character character constant .-Wmultichar." } +#endif diff --git a/gcc/testsuite/gcc.dg/cpp/warn-multichar.c b/gcc/testsuite/gcc.dg/cpp/warn-multichar.c new file mode 100644 index 00000000000..f5b02dad479 --- /dev/null +++ b/gcc/testsuite/gcc.dg/cpp/warn-multichar.c @@ -0,0 +1,5 @@ +// { dg-do preprocess } +// { dg-options "-std=gnu99 -fdiagnostics-show-option -Wmultichar" } + +#if 'abc' // { dg-warning "multi-character character constant .-Wmultichar." } +#endif diff --git a/gcc/testsuite/gcc.dg/cpp/warn-normalized-1.c b/gcc/testsuite/gcc.dg/cpp/warn-normalized-1.c new file mode 100644 index 00000000000..fe1c5753074 --- /dev/null +++ b/gcc/testsuite/gcc.dg/cpp/warn-normalized-1.c @@ -0,0 +1,4 @@ +// { dg-do preprocess } +// { dg-options "-std=gnu99 -fdiagnostics-show-option -fextended-identifiers -Wnormalized=nfc" } + +\u0F43 // { dg-warning "`.U00000f43' is not in NFC .-Wnormalized=." } diff --git a/gcc/testsuite/gcc.dg/cpp/warn-normalized-2.c b/gcc/testsuite/gcc.dg/cpp/warn-normalized-2.c new file mode 100644 index 00000000000..f1fb96833d7 --- /dev/null +++ b/gcc/testsuite/gcc.dg/cpp/warn-normalized-2.c @@ -0,0 +1,4 @@ +// { dg-do preprocess } +// { dg-options "-std=gnu99 -fdiagnostics-show-option -fextended-identifiers -Wnormalized=nfkc" } + +\u00AA // { dg-warning "`.U000000aa' is not in NFKC .-Wnormalized=." } diff --git a/gcc/testsuite/gcc.dg/cpp/warn-normalized-3.c b/gcc/testsuite/gcc.dg/cpp/warn-normalized-3.c new file mode 100644 index 00000000000..380c670b8af --- /dev/null +++ b/gcc/testsuite/gcc.dg/cpp/warn-normalized-3.c @@ -0,0 +1,5 @@ +// { dg-do preprocess } +// { dg-options "-std=gnu99 -fdiagnostics-show-option -fextended-identifiers -Werror=normalized=" } + + // { dg-prune-output ".*-Werror=normalized=: Set -Wnormalized=nfc.*" } +\u0F43 // { dg-error "`.U00000f43' is not in NFC .-Wnormalized=." } diff --git a/gcc/testsuite/gcc.dg/cpp/warn-redefined-2.c b/gcc/testsuite/gcc.dg/cpp/warn-redefined-2.c new file mode 100644 index 00000000000..83cc3df7610 --- /dev/null +++ b/gcc/testsuite/gcc.dg/cpp/warn-redefined-2.c @@ -0,0 +1,18 @@ +// { dg-do preprocess } +// { dg-options "-std=gnu99 -fdiagnostics-show-option -Werror=builtin-macro-redefined" } + +#ifndef __TIME__ +#error "__TIME__ builtin is not defined" +// { dg-bogus "__TIME__ builtin is not defined" "no-time" { target *-*-* } 5 } +#endif + +#define __TIME__ "X" // { dg-error "\"__TIME__\" redefined .-Wbuiltin-macro-redefined." } + +#define __TIME__ "Y" // { dg-bogus "-Wbuiltin-macro-redefined" } + // { dg-warning "\"__TIME__\" redefined" "not-builtin-1" { target *-*-* } 11 } + // { dg-message "previous definition" "previous-1" { target *-*-* } 9 } + +#define X "X" +#define X "Y" // { dg-bogus "-Wbuiltin-macro-redefined" } + // { dg-warning "\"X\" redefined" "not-builtin-2" { target *-*-* } 16 } + // { dg-message "previous definition" "previous-2" { target *-*-* } 15 } diff --git a/gcc/testsuite/gcc.dg/cpp/warn-redefined.c b/gcc/testsuite/gcc.dg/cpp/warn-redefined.c new file mode 100644 index 00000000000..1d3e7fc3ed3 --- /dev/null +++ b/gcc/testsuite/gcc.dg/cpp/warn-redefined.c @@ -0,0 +1,18 @@ +// { dg-do preprocess } +// { dg-options "-std=gnu99 -fdiagnostics-show-option -Wbuiltin-macro-redefined" } + +#ifndef __TIME__ +#error "__TIME__ builtin is not defined" +// { dg-bogus "__TIME__ builtin is not defined" "no-time" { target *-*-* } 5 } +#endif + +#define __TIME__ "X" // { dg-warning "\"__TIME__\" redefined .-Wbuiltin-macro-redefined." } + +#define __TIME__ "Y" // { dg-bogus "-Wbuiltin-macro-redefined" } + // { dg-warning "\"__TIME__\" redefined" "not-builtin-1" { target *-*-* } 11 } + // { dg-message "previous definition" "previous-1" { target *-*-* } 9 } + +#define X "X" +#define X "Y" // { dg-bogus "-Wbuiltin-macro-redefined" } + // { dg-warning "\"X\" redefined" "not-builtin-2" { target *-*-* } 16 } + // { dg-message "previous definition" "previous-2" { target *-*-* } 15 } diff --git a/gcc/testsuite/gcc.dg/cpp/warn-traditional-2.c b/gcc/testsuite/gcc.dg/cpp/warn-traditional-2.c new file mode 100644 index 00000000000..cb5f690ccf7 --- /dev/null +++ b/gcc/testsuite/gcc.dg/cpp/warn-traditional-2.c @@ -0,0 +1,23 @@ +// { dg-do compile } +// { dg-options "-std=gnu99 -fdiagnostics-show-option -Werror=traditional -Wno-deprecated -Wno-long-long" } + +#assert x(x) // { dg-error "suggest hiding #assert from traditional C with an indented # .-Wtraditional." } + + #define X X // { dg-error "traditional C ignores #define with the # indented .-Wtraditional." } + +#if 0 +#elif 1 // { dg-error "suggest not using #elif in traditional C .-Wtraditional." } +#endif + +#define f(X) X +int f; // { dg-error "function-like macro \"f\" must be used with arguments in traditional C .-Wtraditional." } + +#if 0U // { dg-error "traditional C rejects the \"U\" suffix .-Wtraditional." } +#endif + +#if +1 // { dg-error " traditional C rejects the unary plus operator .-Wtraditional." } +#endif + +char *x = "\x0"; // { dg-error "the meaning of '.x' is different in traditional C .-Wtraditional." } +char *y = "\a"; // { dg-error "the meaning of '.a' is different in traditional C .-Wtraditional." } +char *z = "\u0F43"; // { dg-error "the meaning of '.u' is different in traditional C .-Wtraditional." } diff --git a/gcc/testsuite/gcc.dg/cpp/warn-traditional.c b/gcc/testsuite/gcc.dg/cpp/warn-traditional.c new file mode 100644 index 00000000000..f72f6db69d5 --- /dev/null +++ b/gcc/testsuite/gcc.dg/cpp/warn-traditional.c @@ -0,0 +1,23 @@ +// { dg-do compile } +// { dg-options "-std=gnu99 -fdiagnostics-show-option -Wtraditional -Wno-deprecated -Wno-long-long" } + +#assert x(x) // { dg-warning "suggest hiding #assert from traditional C with an indented # .-Wtraditional." } + + #define X X // { dg-warning "traditional C ignores #define with the # indented .-Wtraditional." } + +#if 0 +#elif 1 // { dg-warning "suggest not using #elif in traditional C .-Wtraditional." } +#endif + +#define f(X) X +int f; // { dg-warning "function-like macro \"f\" must be used with arguments in traditional C .-Wtraditional." } + +#if 0U // { dg-warning "traditional C rejects the \"U\" suffix .-Wtraditional." } +#endif + +#if +1 // { dg-warning " traditional C rejects the unary plus operator .-Wtraditional." } +#endif + +char *x = "\x0"; // { dg-warning "the meaning of '.x' is different in traditional C .-Wtraditional." } +char *y = "\a"; // { dg-warning "the meaning of '.a' is different in traditional C .-Wtraditional." } +char *z = "\u0F43"; // { dg-warning "the meaning of '.u' is different in traditional C .-Wtraditional." } diff --git a/gcc/testsuite/gcc.dg/cpp/warn-trigraphs-1.c b/gcc/testsuite/gcc.dg/cpp/warn-trigraphs-1.c new file mode 100644 index 00000000000..4f3779df221 --- /dev/null +++ b/gcc/testsuite/gcc.dg/cpp/warn-trigraphs-1.c @@ -0,0 +1,4 @@ +// { dg-do preprocess } +// { dg-options "-std=gnu99 -fdiagnostics-show-option -trigraphs -Wtrigraphs" } + +??= // { dg-warning "trigraph \\?\\?= converted to # .-Wtrigraphs." } diff --git a/gcc/testsuite/gcc.dg/cpp/warn-trigraphs-2.c b/gcc/testsuite/gcc.dg/cpp/warn-trigraphs-2.c new file mode 100644 index 00000000000..ff87ae54951 --- /dev/null +++ b/gcc/testsuite/gcc.dg/cpp/warn-trigraphs-2.c @@ -0,0 +1,4 @@ +// { dg-do preprocess } +// { dg-options "-std=gnu99 -fdiagnostics-show-option -Wtrigraphs" } + +??= // { dg-warning "trigraph \\?\\?= ignored, use -trigraphs to enable .-Wtrigraphs." } diff --git a/gcc/testsuite/gcc.dg/cpp/warn-trigraphs-3.c b/gcc/testsuite/gcc.dg/cpp/warn-trigraphs-3.c new file mode 100644 index 00000000000..a993e2a190c --- /dev/null +++ b/gcc/testsuite/gcc.dg/cpp/warn-trigraphs-3.c @@ -0,0 +1,4 @@ +// { dg-do preprocess } +// { dg-options "-std=gnu99 -fdiagnostics-show-option -trigraphs -Werror=trigraphs" } + +??= // { dg-error "trigraph \\?\\?= converted to # .-Wtrigraphs." } diff --git a/gcc/testsuite/gcc.dg/cpp/warn-trigraphs-4.c b/gcc/testsuite/gcc.dg/cpp/warn-trigraphs-4.c new file mode 100644 index 00000000000..240ae0f2175 --- /dev/null +++ b/gcc/testsuite/gcc.dg/cpp/warn-trigraphs-4.c @@ -0,0 +1,4 @@ +// { dg-do preprocess } +// { dg-options "-std=gnu99 -fdiagnostics-show-option -Werror=trigraphs" } + +??= // { dg-error "trigraph \\?\\?= ignored, use -trigraphs to enable .-Wtrigraphs." } diff --git a/gcc/testsuite/gcc.dg/cpp/warn-undef-2.c b/gcc/testsuite/gcc.dg/cpp/warn-undef-2.c new file mode 100644 index 00000000000..4eb80e0e945 --- /dev/null +++ b/gcc/testsuite/gcc.dg/cpp/warn-undef-2.c @@ -0,0 +1,5 @@ +// { dg-do preprocess } +// { dg-options "-std=gnu99 -fdiagnostics-show-option -Werror=undef" } + +#if x // { dg-error "\"x\" is not defined .-Wundef." } +#endif diff --git a/gcc/testsuite/gcc.dg/cpp/warn-undef.c b/gcc/testsuite/gcc.dg/cpp/warn-undef.c new file mode 100644 index 00000000000..dd4524d8136 --- /dev/null +++ b/gcc/testsuite/gcc.dg/cpp/warn-undef.c @@ -0,0 +1,5 @@ +// { dg-do preprocess } +// { dg-options "-std=gnu99 -fdiagnostics-show-option -Wundef" } + +#if x // { dg-warning "\"x\" is not defined .-Wundef." } +#endif diff --git a/gcc/testsuite/gcc.dg/cpp/warn-unused-macros-2.c b/gcc/testsuite/gcc.dg/cpp/warn-unused-macros-2.c new file mode 100644 index 00000000000..58eeebfcdd9 --- /dev/null +++ b/gcc/testsuite/gcc.dg/cpp/warn-unused-macros-2.c @@ -0,0 +1,4 @@ +// { dg-do preprocess } +// { dg-options "-std=gnu99 -fdiagnostics-show-option -Werror=unused-macros" } + +#define X X // { dg-error "macro \"X\" is not used .-Wunused-macros." } diff --git a/gcc/testsuite/gcc.dg/cpp/warn-unused-macros.c b/gcc/testsuite/gcc.dg/cpp/warn-unused-macros.c new file mode 100644 index 00000000000..e1ce94eeee6 --- /dev/null +++ b/gcc/testsuite/gcc.dg/cpp/warn-unused-macros.c @@ -0,0 +1,4 @@ +// { dg-do preprocess } +// { dg-options "-std=gnu99 -fdiagnostics-show-option -Wunused-macros" } + +#define X X // { dg-warning "macro \"X\" is not used .-Wunused-macros." } diff --git a/gcc/testsuite/gcc.dg/cpp/warn-variadic-2.c b/gcc/testsuite/gcc.dg/cpp/warn-variadic-2.c new file mode 100644 index 00000000000..f43d96ab81b --- /dev/null +++ b/gcc/testsuite/gcc.dg/cpp/warn-variadic-2.c @@ -0,0 +1,6 @@ +/* { dg-do preprocess } */ +/* { dg-options "-ansi -fdiagnostics-show-option -pedantic -Werror=variadic-macros" } */ + +#define F(...) X /* { dg-error "anonymous variadic macros were introduced in C99 .-Wvariadic-macros." } */ + +#define G(X...) X /* { dg-error "ISO C does not permit named variadic macros .-Wvariadic-macros." } */ diff --git a/gcc/testsuite/gcc.dg/cpp/warn-variadic.c b/gcc/testsuite/gcc.dg/cpp/warn-variadic.c new file mode 100644 index 00000000000..ba66c901813 --- /dev/null +++ b/gcc/testsuite/gcc.dg/cpp/warn-variadic.c @@ -0,0 +1,6 @@ +/* { dg-do preprocess } */ +/* { dg-options "-ansi -fdiagnostics-show-option -pedantic -Wvariadic-macros" } */ + +#define F(...) X /* { dg-warning "anonymous variadic macros were introduced in C99 .-Wvariadic-macros." } */ + +#define G(X...) X /* { dg-warning "ISO C does not permit named variadic macros .-Wvariadic-macros." } */ diff --git a/gcc/testsuite/gcc.dg/cpp/warning-directive-1.c b/gcc/testsuite/gcc.dg/cpp/warning-directive-1.c new file mode 100644 index 00000000000..cb4bd326cc2 --- /dev/null +++ b/gcc/testsuite/gcc.dg/cpp/warning-directive-1.c @@ -0,0 +1,4 @@ +// { dg-do preprocess } +// { dg-options "-std=gnu99 -fdiagnostics-show-option" } + +#warning "Printed" // { dg-warning "\"Printed\" .-Wcpp." } diff --git a/gcc/testsuite/gcc.dg/cpp/warning-directive-2.c b/gcc/testsuite/gcc.dg/cpp/warning-directive-2.c new file mode 100644 index 00000000000..0889803cd11 --- /dev/null +++ b/gcc/testsuite/gcc.dg/cpp/warning-directive-2.c @@ -0,0 +1,4 @@ +// { dg-do preprocess } +// { dg-options "-std=gnu99 -fdiagnostics-show-option -Werror=cpp" } + +#warning "Printed" // { dg-error "\"Printed\" .-Wcpp." } diff --git a/gcc/testsuite/gcc.dg/cpp/warning-directive-3.c b/gcc/testsuite/gcc.dg/cpp/warning-directive-3.c new file mode 100644 index 00000000000..48c97f3ac5b --- /dev/null +++ b/gcc/testsuite/gcc.dg/cpp/warning-directive-3.c @@ -0,0 +1,4 @@ +// { dg-do preprocess } +// { dg-options "-std=gnu99 -fdiagnostics-show-option -Werror -Wno-error=cpp" } + +#warning "Printed" // { dg-warning "\"Printed\" .-Wcpp." } diff --git a/gcc/testsuite/gcc.dg/cpp/warning-directive-4.c b/gcc/testsuite/gcc.dg/cpp/warning-directive-4.c new file mode 100644 index 00000000000..2eb101765da --- /dev/null +++ b/gcc/testsuite/gcc.dg/cpp/warning-directive-4.c @@ -0,0 +1,4 @@ +// { dg-do preprocess } +// { dg-options "-std=gnu99 -fdiagnostics-show-option -Wno-cpp" } + +#warning "Not printed" // { dg-bogus "." } |