aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorEd Smith-Rowland <3dw4rd@verizon.net>2012-11-10 00:08:49 +0000
committerEdward Smith-Rowland <emsr@gcc.gnu.org>2012-11-10 00:08:49 +0000
commita4a0016d60bc7cd8953b162f44c793801e09441c (patch)
tree6f4eb9fb1a2dfd8c43e78bcc98930f16138e78c4 /gcc
parent97996ede57cfd5ea8ab2e1b7c2ff04d311894128 (diff)
downloadgcc-a4a0016d60bc7cd8953b162f44c793801e09441c.zip
gcc-a4a0016d60bc7cd8953b162f44c793801e09441c.tar.gz
gcc-a4a0016d60bc7cd8953b162f44c793801e09441c.tar.bz2
Implement a flag -fext-numeric-literals that allows control of whether GNU...
Implement a flag -fext-numeric-literals that allows control of whether GNU numeric suffix extensions are parsed or passed to C++ as user-defined literals. From-SVN: r193382
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/c-family/ChangeLog6
-rw-r--r--gcc/c-family/c-opts.c16
-rw-r--r--gcc/c-family/c.opt5
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/decl.c4
-rw-r--r--gcc/doc/invoke.texi14
-rw-r--r--gcc/testsuite/ChangeLog8
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/gnu_fext-numeric-literals.C115
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/gnu_fno-ext-numeric-literals.C115
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/std_fext-numeric-literals.C115
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/std_fno-ext-numeric-literals.C115
12 files changed, 519 insertions, 4 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index bc60d18..dde3d21 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2012-11-09 Ed Smith-Rowland <3dw4rd@verizon.net>
+
+ PR c++/54413
+ * doc/invoke.texi: Document f[no-]ext-numeric-literals flag.
+
2012-11-09 Eric Botcazou <ebotcazou@adacore.com>
* doc/install.texi (sparc64-x-solaris2): Mention MPC as well.
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog
index b3234d3..85e113c 100644
--- a/gcc/c-family/ChangeLog
+++ b/gcc/c-family/ChangeLog
@@ -1,3 +1,9 @@
+2012-11-09 Ed Smith-Rowland <3dw4rd@verizon.net>
+
+ PR c++/54413
+ * c-opts.c (c_common_handle_option): Set new flags.
+ * c.opt: Describe new flags.
+
2012-11-09 Jason Merrill <jason@redhat.com>
* c.opt (Wabi-tag): New.
diff --git a/gcc/c-family/c-opts.c b/gcc/c-family/c-opts.c
index eb6b2d9..d86a165 100644
--- a/gcc/c-family/c-opts.c
+++ b/gcc/c-family/c-opts.c
@@ -578,6 +578,10 @@ c_common_handle_option (size_t scode, const char *arg, int value,
set_struct_debug_option (&global_options, loc, arg);
break;
+ case OPT_fext_numeric_literals:
+ cpp_opts->ext_numeric_literals = value;
+ break;
+
case OPT_idirafter:
add_path (xstrdup (arg), AFTER, 0, true);
break;
@@ -660,13 +664,21 @@ c_common_handle_option (size_t scode, const char *arg, int value,
case OPT_std_c__11:
case OPT_std_gnu__11:
if (!preprocessing_asm_p)
- set_std_cxx11 (code == OPT_std_c__11 /* ISO */);
+ {
+ set_std_cxx11 (code == OPT_std_c__11 /* ISO */);
+ if (code == OPT_std_c__11)
+ cpp_opts->ext_numeric_literals = 0;
+ }
break;
case OPT_std_c__1y:
case OPT_std_gnu__1y:
if (!preprocessing_asm_p)
- set_std_cxx1y (code == OPT_std_c__11 /* ISO */);
+ {
+ set_std_cxx1y (code == OPT_std_c__1y /* ISO */);
+ if (code == OPT_std_c__1y)
+ cpp_opts->ext_numeric_literals = 0;
+ }
break;
case OPT_std_c90:
diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt
index fe1fc4d..1b5c51a 100644
--- a/gcc/c-family/c.opt
+++ b/gcc/c-family/c.opt
@@ -1234,6 +1234,11 @@ femit-struct-debug-detailed=
C ObjC C++ ObjC++ Joined
-femit-struct-debug-detailed=<spec-list> Detailed reduced debug info for structs
+fext-numeric-literals
+C++ ObjC++
+Interpret imaginary, fixed-point, or other gnu number suffix as the corresponding
+number literal rather than a user-defined number literal.
+
idirafter
C ObjC C++ ObjC++ Joined Separate MissingArgError(missing path after %qs)
-idirafter <dir> Add <dir> to the end of the system include path
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 59167be..f9bc3bd 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,8 @@
+2012-11-09 Ed Smith-Rowland <3dw4rd@verizon.net>
+
+ PR c++/54413
+ * decl.c (grokfndecl): Adjust calls to interpret_x_suffix.
+
2012-11-09 Jason Merrill <jason@redhat.com>
PR c++/54859
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index f85901f..420937e 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -7567,13 +7567,13 @@ grokfndecl (tree ctype,
suffix = UDLIT_OP_SUFFIX (DECL_NAME (decl));
if (long_long_unsigned_p)
{
- if (cpp_interpret_int_suffix (suffix, strlen (suffix)))
+ if (cpp_interpret_int_suffix (parse_in, suffix, strlen (suffix)))
warning (0, "integer suffix %<%s%>"
" shadowed by implementation", suffix);
}
else if (long_double_p)
{
- if (cpp_interpret_float_suffix (suffix, strlen (suffix)))
+ if (cpp_interpret_float_suffix (parse_in, suffix, strlen (suffix)))
warning (0, "floating point suffix %<%s%>"
" shadowed by implementation", suffix);
}
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 715f60a..9477ffc 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -197,6 +197,7 @@ in the following sections.
-fno-threadsafe-statics -fuse-cxa-atexit -fno-weak -nostdinc++ @gol
-fno-default-inline -fvisibility-inlines-hidden @gol
-fvisibility-ms-compat @gol
+-fext-numeric-literals @gol
-Wabi -Wconversion-null -Wctor-dtor-privacy @gol
-Wdelete-non-virtual-dtor -Wliteral-suffix -Wnarrowing @gol
-Wnoexcept -Wnon-virtual-dtor -Wreorder @gol
@@ -2515,6 +2516,19 @@ struct A @{
The compiler rearranges the member initializers for @samp{i}
and @samp{j} to match the declaration order of the members, emitting
a warning to that effect. This warning is enabled by @option{-Wall}.
+
+@item -fext-numeric-literals @r{(C++ and Objective-C++ only)}
+@opindex fext-numeric-literals
+@opindex fno-ext-numeric-literals
+Accept imaginary, fixed-point, or machine-defined
+literal number suffixes as GNU extensions.
+When this option is turned off these suffixes are treated
+as C++11 user-defined literal numeric suffixes.
+This is on by default for all pre-C++11 dialects and all GNU dialects:
+@option{-std=c++98}, @option{-std=gnu++98}, @option{-std=gnu++11},
+@option{-std=gnu++1y}.
+This option is off by default
+for ISO C++11 onwards (@option{-std=c++11}, ...).
@end table
The following @option{-W@dots{}} options are not affected by @option{-Wall}.
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index a9a6ab6..a3ea50f 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,11 @@
+2012-11-09 Ed Smith-Rowland <3dw4rd@verizon.net>
+
+ PR c++/54413
+ * g++.dg/cpp0x/gnu_fext-numeric-literals.C: New.
+ * g++.dg/cpp0x/std_fext-numeric-literals.C: New.
+ * g++.dg/cpp0x/gnu_fno-ext-numeric-literals.C: New.
+ * g++.dg/cpp0x/std_fno-ext-numeric-literals.C: New.
+
2012-11-09 Siddhesh Poyarekar <siddhesh@redhat.com>
* gcc.dg/Warray-bounds-3.c (bar): Keep array access within
diff --git a/gcc/testsuite/g++.dg/cpp0x/gnu_fext-numeric-literals.C b/gcc/testsuite/g++.dg/cpp0x/gnu_fext-numeric-literals.C
new file mode 100644
index 0000000..f4ccd26
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/gnu_fext-numeric-literals.C
@@ -0,0 +1,115 @@
+// { dg-do compile }
+// { dg-options "-std=gnu++11" }
+
+// Integer imaginary...
+
+constexpr unsigned long long
+operator"" i(unsigned long long n) // { dg-warning "shadowed by implementation" }
+{ return 4 * n + 0; }
+
+constexpr unsigned long long
+operator"" I(unsigned long long n) // { dg-warning "shadowed by implementation" }
+{ return 4 * n + 1; }
+
+constexpr unsigned long long
+operator"" j(unsigned long long n) // { dg-warning "shadowed by implementation" }
+{ return 4 * n + 2; }
+
+constexpr unsigned long long
+operator"" J(unsigned long long n) // { dg-warning "shadowed by implementation" }
+{ return 4 * n + 3; }
+
+// Floating-point imaginary...
+
+constexpr long double
+operator"" i(long double n) // { dg-warning "shadowed by implementation" }
+{ return 4.0L * n + 0.0L; }
+
+constexpr long double
+operator"" I(long double n) // { dg-warning "shadowed by implementation" }
+{ return 4.0L * n + 1.0L; }
+
+constexpr long double
+operator"" j(long double n) // { dg-warning "shadowed by implementation" }
+{ return 4.0L * n + 2.0L; }
+
+constexpr long double
+operator"" J(long double n) // { dg-warning "shadowed by implementation" }
+{ return 4.0L * n + 3.0L; }
+
+// Fixed-point...
+
+constexpr long double
+operator"" k(long double n) // { dg-warning "shadowed by implementation" }
+{ return 4 * (n + 1) + 0; }
+
+constexpr long double
+operator"" K(long double n) // { dg-warning "shadowed by implementation" }
+{ return 4 * (n + 1) + 1; }
+
+constexpr long double
+operator"" r(long double n) // { dg-warning "shadowed by implementation" }
+{ return 4 * (n + 1) + 2; }
+
+constexpr long double
+operator"" R(long double n) // { dg-warning "shadowed by implementation" }
+{ return 4 * (n + 1) + 3; }
+
+// Machine-defined...
+
+constexpr long double
+operator"" w(long double n) // { dg-warning "shadowed by implementation" }
+{ return 4 * (n + 2) + 0; }
+
+constexpr long double
+operator"" W(long double n) // { dg-warning "shadowed by implementation" }
+{ return 4 * (n + 2) + 1; }
+
+constexpr long double
+operator"" q(long double n) // { dg-warning "shadowed by implementation" }
+{ return 4 * (n + 2) + 2; }
+
+constexpr long double
+operator"" Q(long double n) // { dg-warning "shadowed by implementation" }
+{ return 4 * (n + 2) + 3; }
+
+int
+main()
+{
+ auto ii = 1i;
+ auto Ii = 1I;
+ auto ji = 1j;
+ auto Ji = 1J;
+
+ auto ifp = 1.0i;
+ auto Ifp = 1.0I;
+ auto jfp = 1.0j;
+ auto Jfp = 1.0J;
+
+ auto kfp = 1.0k; // { dg-error "fixed-point types not supported" }
+ auto Kfp = 1.0K; // { dg-error "fixed-point types not supported" }
+ auto rfp = 1.0r; // { dg-error "fixed-point types not supported" }
+ auto Rfp = 1.0R; // { dg-error "fixed-point types not supported" }
+
+ auto wfp = 1.0w;
+ auto Wfp = 1.0W;
+ auto qfp = 1.0q;
+ auto Qfp = 1.0Q;
+}
+
+// { dg-warning "literal operator suffixes not preceded by" "" { target *-*-* } 7 }
+// { dg-warning "literal operator suffixes not preceded by" "" { target *-*-* } 11 }
+// { dg-warning "literal operator suffixes not preceded by" "" { target *-*-* } 15 }
+// { dg-warning "literal operator suffixes not preceded by" "" { target *-*-* } 19 }
+// { dg-warning "literal operator suffixes not preceded by" "" { target *-*-* } 25 }
+// { dg-warning "literal operator suffixes not preceded by" "" { target *-*-* } 29 }
+// { dg-warning "literal operator suffixes not preceded by" "" { target *-*-* } 33 }
+// { dg-warning "literal operator suffixes not preceded by" "" { target *-*-* } 37 }
+// { dg-warning "literal operator suffixes not preceded by" "" { target *-*-* } 43 }
+// { dg-warning "literal operator suffixes not preceded by" "" { target *-*-* } 47 }
+// { dg-warning "literal operator suffixes not preceded by" "" { target *-*-* } 51 }
+// { dg-warning "literal operator suffixes not preceded by" "" { target *-*-* } 55 }
+// { dg-warning "literal operator suffixes not preceded by" "" { target *-*-* } 61 }
+// { dg-warning "literal operator suffixes not preceded by" "" { target *-*-* } 65 }
+// { dg-warning "literal operator suffixes not preceded by" "" { target *-*-* } 69 }
+// { dg-warning "literal operator suffixes not preceded by" "" { target *-*-* } 73 }
diff --git a/gcc/testsuite/g++.dg/cpp0x/gnu_fno-ext-numeric-literals.C b/gcc/testsuite/g++.dg/cpp0x/gnu_fno-ext-numeric-literals.C
new file mode 100644
index 0000000..94fd8fc
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/gnu_fno-ext-numeric-literals.C
@@ -0,0 +1,115 @@
+// { dg-do compile }
+// { dg-options "-std=gnu++11 -fno-ext-numeric-literals" }
+
+// Integer imaginary...
+
+constexpr unsigned long long
+operator"" i(unsigned long long n)
+{ return 4 * n + 0; }
+
+constexpr unsigned long long
+operator"" I(unsigned long long n)
+{ return 4 * n + 1; }
+
+constexpr unsigned long long
+operator"" j(unsigned long long n)
+{ return 4 * n + 2; }
+
+constexpr unsigned long long
+operator"" J(unsigned long long n)
+{ return 4 * n + 3; }
+
+// Floating-point imaginary...
+
+constexpr long double
+operator"" i(long double n)
+{ return 4.0L * n + 0.0L; }
+
+constexpr long double
+operator"" I(long double n)
+{ return 4.0L * n + 1.0L; }
+
+constexpr long double
+operator"" j(long double n)
+{ return 4.0L * n + 2.0L; }
+
+constexpr long double
+operator"" J(long double n)
+{ return 4.0L * n + 3.0L; }
+
+// Fixed-point...
+
+constexpr long double
+operator"" k(long double n)
+{ return 4 * (n + 1) + 0; }
+
+constexpr long double
+operator"" K(long double n)
+{ return 4 * (n + 1) + 1; }
+
+constexpr long double
+operator"" r(long double n)
+{ return 4 * (n + 1) + 2; }
+
+constexpr long double
+operator"" R(long double n)
+{ return 4 * (n + 1) + 3; }
+
+// Machine-defined...
+
+constexpr long double
+operator"" w(long double n)
+{ return 4 * (n + 2) + 0; }
+
+constexpr long double
+operator"" W(long double n)
+{ return 4 * (n + 2) + 1; }
+
+constexpr long double
+operator"" q(long double n)
+{ return 4 * (n + 2) + 2; }
+
+constexpr long double
+operator"" Q(long double n)
+{ return 4 * (n + 2) + 3; }
+
+int
+main()
+{
+ auto ii = 1i;
+ auto Ii = 1I;
+ auto ji = 1j;
+ auto Ji = 1J;
+
+ auto ifp = 1.0i;
+ auto Ifp = 1.0I;
+ auto jfp = 1.0j;
+ auto Jfp = 1.0J;
+
+ auto kfp = 1.0k;
+ auto Kfp = 1.0K;
+ auto rfp = 1.0r;
+ auto Rfp = 1.0R;
+
+ auto wfp = 1.0w;
+ auto Wfp = 1.0W;
+ auto qfp = 1.0q;
+ auto Qfp = 1.0Q;
+}
+
+// { dg-warning "literal operator suffixes not preceded by" "" { target *-*-* } 7 }
+// { dg-warning "literal operator suffixes not preceded by" "" { target *-*-* } 11 }
+// { dg-warning "literal operator suffixes not preceded by" "" { target *-*-* } 15 }
+// { dg-warning "literal operator suffixes not preceded by" "" { target *-*-* } 19 }
+// { dg-warning "literal operator suffixes not preceded by" "" { target *-*-* } 25 }
+// { dg-warning "literal operator suffixes not preceded by" "" { target *-*-* } 29 }
+// { dg-warning "literal operator suffixes not preceded by" "" { target *-*-* } 33 }
+// { dg-warning "literal operator suffixes not preceded by" "" { target *-*-* } 37 }
+// { dg-warning "literal operator suffixes not preceded by" "" { target *-*-* } 43 }
+// { dg-warning "literal operator suffixes not preceded by" "" { target *-*-* } 47 }
+// { dg-warning "literal operator suffixes not preceded by" "" { target *-*-* } 51 }
+// { dg-warning "literal operator suffixes not preceded by" "" { target *-*-* } 55 }
+// { dg-warning "literal operator suffixes not preceded by" "" { target *-*-* } 61 }
+// { dg-warning "literal operator suffixes not preceded by" "" { target *-*-* } 65 }
+// { dg-warning "literal operator suffixes not preceded by" "" { target *-*-* } 69 }
+// { dg-warning "literal operator suffixes not preceded by" "" { target *-*-* } 73 }
diff --git a/gcc/testsuite/g++.dg/cpp0x/std_fext-numeric-literals.C b/gcc/testsuite/g++.dg/cpp0x/std_fext-numeric-literals.C
new file mode 100644
index 0000000..d59c181
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/std_fext-numeric-literals.C
@@ -0,0 +1,115 @@
+// { dg-do compile }
+// { dg-options "-std=c++11 -fext-numeric-literals" }
+
+// Integer imaginary...
+
+constexpr unsigned long long
+operator"" i(unsigned long long n) // { dg-warning "shadowed by implementation" }
+{ return 4 * n + 0; }
+
+constexpr unsigned long long
+operator"" I(unsigned long long n) // { dg-warning "shadowed by implementation" }
+{ return 4 * n + 1; }
+
+constexpr unsigned long long
+operator"" j(unsigned long long n) // { dg-warning "shadowed by implementation" }
+{ return 4 * n + 2; }
+
+constexpr unsigned long long
+operator"" J(unsigned long long n) // { dg-warning "shadowed by implementation" }
+{ return 4 * n + 3; }
+
+// Floating-point imaginary...
+
+constexpr long double
+operator"" i(long double n) // { dg-warning "shadowed by implementation" }
+{ return 4.0L * n + 0.0L; }
+
+constexpr long double
+operator"" I(long double n) // { dg-warning "shadowed by implementation" }
+{ return 4.0L * n + 1.0L; }
+
+constexpr long double
+operator"" j(long double n) // { dg-warning "shadowed by implementation" }
+{ return 4.0L * n + 2.0L; }
+
+constexpr long double
+operator"" J(long double n) // { dg-warning "shadowed by implementation" }
+{ return 4.0L * n + 3.0L; }
+
+// Fixed-point...
+
+constexpr long double
+operator"" k(long double n) // { dg-warning "shadowed by implementation" }
+{ return 4 * (n + 1) + 0; }
+
+constexpr long double
+operator"" K(long double n) // { dg-warning "shadowed by implementation" }
+{ return 4 * (n + 1) + 1; }
+
+constexpr long double
+operator"" r(long double n) // { dg-warning "shadowed by implementation" }
+{ return 4 * (n + 1) + 2; }
+
+constexpr long double
+operator"" R(long double n) // { dg-warning "shadowed by implementation" }
+{ return 4 * (n + 1) + 3; }
+
+// Machine-defined...
+
+constexpr long double
+operator"" w(long double n) // { dg-warning "shadowed by implementation" }
+{ return 4 * (n + 2) + 0; }
+
+constexpr long double
+operator"" W(long double n) // { dg-warning "shadowed by implementation" }
+{ return 4 * (n + 2) + 1; }
+
+constexpr long double
+operator"" q(long double n) // { dg-warning "shadowed by implementation" }
+{ return 4 * (n + 2) + 2; }
+
+constexpr long double
+operator"" Q(long double n) // { dg-warning "shadowed by implementation" }
+{ return 4 * (n + 2) + 3; }
+
+int
+main()
+{
+ auto ii = 1i;
+ auto Ii = 1I;
+ auto ji = 1j;
+ auto Ji = 1J;
+
+ auto ifp = 1.0i;
+ auto Ifp = 1.0I;
+ auto jfp = 1.0j;
+ auto Jfp = 1.0J;
+
+ auto kfp = 1.0k; // { dg-error "fixed-point types not supported" }
+ auto Kfp = 1.0K; // { dg-error "fixed-point types not supported" }
+ auto rfp = 1.0r; // { dg-error "fixed-point types not supported" }
+ auto Rfp = 1.0R; // { dg-error "fixed-point types not supported" }
+
+ auto wfp = 1.0w;
+ auto Wfp = 1.0W;
+ auto qfp = 1.0q;
+ auto Qfp = 1.0Q;
+}
+
+// { dg-warning "literal operator suffixes not preceded by" "" { target *-*-* } 7 }
+// { dg-warning "literal operator suffixes not preceded by" "" { target *-*-* } 11 }
+// { dg-warning "literal operator suffixes not preceded by" "" { target *-*-* } 15 }
+// { dg-warning "literal operator suffixes not preceded by" "" { target *-*-* } 19 }
+// { dg-warning "literal operator suffixes not preceded by" "" { target *-*-* } 25 }
+// { dg-warning "literal operator suffixes not preceded by" "" { target *-*-* } 29 }
+// { dg-warning "literal operator suffixes not preceded by" "" { target *-*-* } 33 }
+// { dg-warning "literal operator suffixes not preceded by" "" { target *-*-* } 37 }
+// { dg-warning "literal operator suffixes not preceded by" "" { target *-*-* } 43 }
+// { dg-warning "literal operator suffixes not preceded by" "" { target *-*-* } 47 }
+// { dg-warning "literal operator suffixes not preceded by" "" { target *-*-* } 51 }
+// { dg-warning "literal operator suffixes not preceded by" "" { target *-*-* } 55 }
+// { dg-warning "literal operator suffixes not preceded by" "" { target *-*-* } 61 }
+// { dg-warning "literal operator suffixes not preceded by" "" { target *-*-* } 65 }
+// { dg-warning "literal operator suffixes not preceded by" "" { target *-*-* } 69 }
+// { dg-warning "literal operator suffixes not preceded by" "" { target *-*-* } 73 }
diff --git a/gcc/testsuite/g++.dg/cpp0x/std_fno-ext-numeric-literals.C b/gcc/testsuite/g++.dg/cpp0x/std_fno-ext-numeric-literals.C
new file mode 100644
index 0000000..488db42
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/std_fno-ext-numeric-literals.C
@@ -0,0 +1,115 @@
+// { dg-do compile }
+// { dg-options "-std=c++11" }
+
+// Integer imaginary...
+
+constexpr unsigned long long
+operator"" i(unsigned long long n)
+{ return 4 * n + 0; }
+
+constexpr unsigned long long
+operator"" I(unsigned long long n)
+{ return 4 * n + 1; }
+
+constexpr unsigned long long
+operator"" j(unsigned long long n)
+{ return 4 * n + 2; }
+
+constexpr unsigned long long
+operator"" J(unsigned long long n)
+{ return 4 * n + 3; }
+
+// Floating-point imaginary...
+
+constexpr long double
+operator"" i(long double n)
+{ return 4.0L * n + 0.0L; }
+
+constexpr long double
+operator"" I(long double n)
+{ return 4.0L * n + 1.0L; }
+
+constexpr long double
+operator"" j(long double n)
+{ return 4.0L * n + 2.0L; }
+
+constexpr long double
+operator"" J(long double n)
+{ return 4.0L * n + 3.0L; }
+
+// Fixed-point...
+
+constexpr long double
+operator"" k(long double n)
+{ return 4 * (n + 1) + 0; }
+
+constexpr long double
+operator"" K(long double n)
+{ return 4 * (n + 1) + 1; }
+
+constexpr long double
+operator"" r(long double n)
+{ return 4 * (n + 1) + 2; }
+
+constexpr long double
+operator"" R(long double n)
+{ return 4 * (n + 1) + 3; }
+
+// Machine-defined...
+
+constexpr long double
+operator"" w(long double n)
+{ return 4 * (n + 2) + 0; }
+
+constexpr long double
+operator"" W(long double n)
+{ return 4 * (n + 2) + 1; }
+
+constexpr long double
+operator"" q(long double n)
+{ return 4 * (n + 2) + 2; }
+
+constexpr long double
+operator"" Q(long double n)
+{ return 4 * (n + 2) + 3; }
+
+int
+main()
+{
+ auto ii = 1i;
+ auto Ii = 1I;
+ auto ji = 1j;
+ auto Ji = 1J;
+
+ auto ifp = 1.0i;
+ auto Ifp = 1.0I;
+ auto jfp = 1.0j;
+ auto Jfp = 1.0J;
+
+ auto kfp = 1.0k;
+ auto Kfp = 1.0K;
+ auto rfp = 1.0r;
+ auto Rfp = 1.0R;
+
+ auto wfp = 1.0w;
+ auto Wfp = 1.0W;
+ auto qfp = 1.0q;
+ auto Qfp = 1.0Q;
+}
+
+// { dg-warning "literal operator suffixes not preceded by" "" { target *-*-* } 7 }
+// { dg-warning "literal operator suffixes not preceded by" "" { target *-*-* } 11 }
+// { dg-warning "literal operator suffixes not preceded by" "" { target *-*-* } 15 }
+// { dg-warning "literal operator suffixes not preceded by" "" { target *-*-* } 19 }
+// { dg-warning "literal operator suffixes not preceded by" "" { target *-*-* } 25 }
+// { dg-warning "literal operator suffixes not preceded by" "" { target *-*-* } 29 }
+// { dg-warning "literal operator suffixes not preceded by" "" { target *-*-* } 33 }
+// { dg-warning "literal operator suffixes not preceded by" "" { target *-*-* } 37 }
+// { dg-warning "literal operator suffixes not preceded by" "" { target *-*-* } 43 }
+// { dg-warning "literal operator suffixes not preceded by" "" { target *-*-* } 47 }
+// { dg-warning "literal operator suffixes not preceded by" "" { target *-*-* } 51 }
+// { dg-warning "literal operator suffixes not preceded by" "" { target *-*-* } 55 }
+// { dg-warning "literal operator suffixes not preceded by" "" { target *-*-* } 61 }
+// { dg-warning "literal operator suffixes not preceded by" "" { target *-*-* } 65 }
+// { dg-warning "literal operator suffixes not preceded by" "" { target *-*-* } 69 }
+// { dg-warning "literal operator suffixes not preceded by" "" { target *-*-* } 73 }