I sent this to the wrong list originally, apologies to those who get it
twice.
There is a request to be able to turn off interpretation of several
suffixes for gcc extension numeric literals to make way for C++-1Y or
various std libraries to claim several suffixes currently used for gnu
extensions.
This patch interprets the suffixes according to the current extension
rules by default. But if -std=c++1y is used as the C++ standard then
the flags are off by default allowing use as C+11 user-defined literals.
I would like to get this into 4.8 if I can.
It passes on x86_64 linux.
Regards,
Ed
libcpp
2012-11-05 Ed Smith-Rowland <3dw...@verizon.net>
PR c++/54413
* include/cpplib.h (cpp_interpret_float_suffix): Add cpp_reader* arg.
(cpp_interpret_int_suffix): Add cpp_reader* arg.
* init.c (cpp_create_reader): Iitialize new flags.
* expr.c (interpret_float_suffix): Use new flags.
(cpp_interpret_float_suffix): Add cpp_reader* arg.
(interpret_int_suffix): Use new flags.
(cpp_interpret_int_suffix): Add cpp_reader* arg.
(cpp_classify_number): Adjust calls to interpret_x_suffix.
gcc/c-family
2012-11-05 Ed Smith-Rowland <3dw...@verizon.net>
PR c++/54413
* c-opts.c (c_common_handle_option): Set new flags.
* c.opt: Describe new flags.
gcc/cp
2012-11-05 Ed Smith-Rowland <3dw...@verizon.net>
PR c++/54413
* decl.c (grokfndecl): Adjust calls to interpret_x_suffix.
gcc/testsuite
2012-11-05 Ed Smith-Rowland <3dw...@verizon.net>
PR c++/54413
* g++.dg/cpp0x/fno-fixed-point-literals.C: New.
* g++.dg/cpp0x/fno-imaginary-literals.C: New.
* g++.dg/cpp0x/fno-machine-defined-literals.C: New.
* g++.dg/cpp0x/ffixed-point-literals.C: New.
* g++.dg/cpp0x/fimaginary-literals.C: New.
* g++.dg/cpp0x/fmachine-defined-literals.C: New.
Index: libcpp/include/cpplib.h
===================================================================
--- libcpp/include/cpplib.h (revision 192897)
+++ libcpp/include/cpplib.h (working copy)
@@ -431,6 +431,18 @@
ud-suffix which does not beging with an underscore. */
unsigned char warn_literal_suffix;
+ /* Nonzero means interpret imaginary number suffix as an imaginary number
+ literal. */
+ unsigned char imaginary_literals;
+
+ /* Nonzero means interpret fixed-point number suffix as a fixed-point number
+ literal. */
+ unsigned char fixed_point_literals;
+
+ /* Nonzero means interpret fixed-point number suffix as amachine-defined
+ number literal. */
+ unsigned char machine_defined_literals;
+
/* Holds the name of the target (execution) character set. */
const char *narrow_charset;
@@ -854,10 +866,12 @@
const char **, source_location);
/* Return the classification flags for a float suffix. */
-extern unsigned int cpp_interpret_float_suffix (const char *, size_t);
+extern unsigned int cpp_interpret_float_suffix (cpp_reader *, const char *,
+ size_t);
/* Return the classification flags for an int suffix. */
-extern unsigned int cpp_interpret_int_suffix (const char *, size_t);
+extern unsigned int cpp_interpret_int_suffix (cpp_reader *, const char *,
+ size_t);
/* Evaluate a token classified as category CPP_N_INTEGER. */
extern cpp_num cpp_interpret_integer (cpp_reader *, const cpp_token *,
Index: libcpp/init.c
===================================================================
--- libcpp/init.c (revision 192897)
+++ libcpp/init.c (working copy)
@@ -182,6 +182,9 @@
CPP_OPTION (pfile, track_macro_expansion) = 2;
CPP_OPTION (pfile, warn_normalize) = normalized_C;
CPP_OPTION (pfile, warn_literal_suffix) = 1;
+ CPP_OPTION (pfile, imaginary_literals) = 1;
+ CPP_OPTION (pfile, fixed_point_literals) = 1;
+ CPP_OPTION (pfile, machine_defined_literals) = 1;
/* Default CPP arithmetic to something sensible for the host for the
benefit of dumb users like fix-header. */
Index: libcpp/expr.c
===================================================================
--- libcpp/expr.c (revision 192897)
+++ libcpp/expr.c (working copy)
@@ -61,8 +61,8 @@
static cpp_num parse_defined (cpp_reader *);
static cpp_num eval_token (cpp_reader *, const cpp_token *, source_location);
static struct op *reduce (cpp_reader *, struct op *, enum cpp_ttype);
-static unsigned int interpret_float_suffix (const uchar *, size_t);
-static unsigned int interpret_int_suffix (const uchar *, size_t);
+static unsigned int interpret_float_suffix (cpp_reader *, const uchar *,
size_t);
+static unsigned int interpret_int_suffix (cpp_reader *, const uchar *, size_t);
static void check_promotion (cpp_reader *, const struct op *);
/* Token type abuse to create unary plus and minus operators. */
@@ -87,7 +87,7 @@
length LEN, possibly zero. Returns 0 for an invalid suffix, or a
flag vector describing the suffix. */
static unsigned int
-interpret_float_suffix (const uchar *s, size_t len)
+interpret_float_suffix (cpp_reader *pfile, const uchar *s, size_t len)
{
size_t flags;
size_t f, d, l, w, q, i;
@@ -115,55 +115,58 @@
}
}
- /* Recognize a fixed-point suffix. */
- if (len != 0)
- switch (s[len-1])
- {
- case 'k': case 'K': flags = CPP_N_ACCUM; break;
- case 'r': case 'R': flags = CPP_N_FRACT; break;
- default: break;
- }
-
- /* Continue processing a fixed-point suffix. The suffix is case
- insensitive except for ll or LL. Order is significant. */
- if (flags)
+ if (CPP_OPTION (pfile, fixed_point_literals))
{
- if (len == 1)
- return flags;
- len--;
+ /* Recognize a fixed-point suffix. */
+ if (len != 0)
+ switch (s[len-1])
+ {
+ case 'k': case 'K': flags = CPP_N_ACCUM; break;
+ case 'r': case 'R': flags = CPP_N_FRACT; break;
+ default: break;
+ }
- if (*s == 'u' || *s == 'U')
+ /* Continue processing a fixed-point suffix. The suffix is case
+ insensitive except for ll or LL. Order is significant. */
+ if (flags)
{
- flags |= CPP_N_UNSIGNED;
if (len == 1)
return flags;
len--;
- s++;
- }
- switch (*s)
- {
- case 'h': case 'H':
- if (len == 1)
- return flags |= CPP_N_SMALL;
- break;
- case 'l':
- if (len == 1)
- return flags |= CPP_N_MEDIUM;
- if (len == 2 && s[1] == 'l')
- return flags |= CPP_N_LARGE;
- break;
- case 'L':
- if (len == 1)
- return flags |= CPP_N_MEDIUM;
- if (len == 2 && s[1] == 'L')
- return flags |= CPP_N_LARGE;
- break;
- default:
- break;
- }
- /* Anything left at this point is invalid. */
- return 0;
+ if (*s == 'u' || *s == 'U')
+ {
+ flags |= CPP_N_UNSIGNED;
+ if (len == 1)
+ return flags;
+ len--;
+ s++;
+ }
+
+ switch (*s)
+ {
+ case 'h': case 'H':
+ if (len == 1)
+ return flags |= CPP_N_SMALL;
+ break;
+ case 'l':
+ if (len == 1)
+ return flags |= CPP_N_MEDIUM;
+ if (len == 2 && s[1] == 'l')
+ return flags |= CPP_N_LARGE;
+ break;
+ case 'L':
+ if (len == 1)
+ return flags |= CPP_N_MEDIUM;
+ if (len == 2 && s[1] == 'L')
+ return flags |= CPP_N_LARGE;
+ break;
+ default:
+ break;
+ }
+ /* Anything left at this point is invalid. */
+ return 0;
+ }
}
/* In any remaining valid suffix, the case and order don't matter. */
@@ -184,6 +187,12 @@
if (f + d + l + w + q > 1 || i > 1)
return 0;
+ if (i && !CPP_OPTION (pfile, imaginary_literals))
+ return 0;
+
+ if ((w || q) && !CPP_OPTION (pfile, machine_defined_literals))
+ return 0;
+
return ((i ? CPP_N_IMAGINARY : 0)
| (f ? CPP_N_SMALL :
d ? CPP_N_MEDIUM :
@@ -194,16 +203,16 @@
/* Return the classification flags for a float suffix. */
unsigned int
-cpp_interpret_float_suffix (const char *s, size_t len)
+cpp_interpret_float_suffix (cpp_reader *pfile, const char *s, size_t len)
{
- return interpret_float_suffix ((const unsigned char *)s, len);
+ return interpret_float_suffix (pfile, (const unsigned char *)s, len);
}
/* Subroutine of cpp_classify_number. S points to an integer suffix
of length LEN, possibly zero. Returns 0 for an invalid suffix, or a
flag vector describing the suffix. */
static unsigned int
-interpret_int_suffix (const uchar *s, size_t len)
+interpret_int_suffix (cpp_reader *pfile, const uchar *s, size_t len)
{
size_t u, l, i;
@@ -227,6 +236,9 @@
if (l > 2 || u > 1 || i > 1)
return 0;
+ if (i && !CPP_OPTION (pfile, imaginary_literals))
+ return 0;
+
return ((i ? CPP_N_IMAGINARY : 0)
| (u ? CPP_N_UNSIGNED : 0)
| ((l == 0) ? CPP_N_SMALL
@@ -235,9 +247,9 @@
/* Return the classification flags for an int suffix. */
unsigned int
-cpp_interpret_int_suffix (const char *s, size_t len)
+cpp_interpret_int_suffix (cpp_reader *pfile, const char *s, size_t len)
{
- return interpret_int_suffix ((const unsigned char *)s, len);
+ return interpret_int_suffix (pfile, (const unsigned char *)s, len);
}
/* Return the string type corresponding to the the input user-defined string
@@ -455,7 +467,7 @@
/* The suffix may be for decimal fixed-point constants without exponent. */
if (radix != 16 && float_flag == NOT_FLOAT)
{
- result = interpret_float_suffix (str, limit - str);
+ result = interpret_float_suffix (pfile, str, limit - str);
if ((result & CPP_N_FRACT) || (result & CPP_N_ACCUM))
{
result |= CPP_N_FLOATING;
@@ -519,7 +531,7 @@
SYNTAX_ERROR_AT (virtual_location,
"hexadecimal floating constants require an exponent");
- result = interpret_float_suffix (str, limit - str);
+ result = interpret_float_suffix (pfile, str, limit - str);
if (result == 0)
{
if (CPP_OPTION (pfile, user_literals))
@@ -573,7 +585,7 @@
}
else
{
- result = interpret_int_suffix (str, limit - str);
+ result = interpret_int_suffix (pfile, str, limit - str);
if (result == 0)
{
if (CPP_OPTION (pfile, user_literals))
Index: gcc/c-family/c-opts.c
===================================================================
--- gcc/c-family/c-opts.c (revision 193124)
+++ gcc/c-family/c-opts.c (working copy)
@@ -629,6 +629,18 @@
set_struct_debug_option (&global_options, loc, arg);
break;
+ case OPT_fimaginary_literals:
+ cpp_opts->imaginary_literals = value;
+ break;
+
+ case OPT_ffixed_point_literals:
+ cpp_opts->fixed_point_literals = value;
+ break;
+
+ case OPT_fmachine_defined_literals:
+ cpp_opts->machine_defined_literals = value;
+ break;
+
case OPT_idirafter:
add_path (xstrdup (arg), AFTER, 0, true);
break;
@@ -721,7 +733,12 @@
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__11 /* ISO */);
+ cpp_opts->imaginary_literals = 0;
+ cpp_opts->fixed_point_literals = 0;
+ cpp_opts->machine_defined_literals = 0;
+ }
break;
case OPT_std_c90:
Index: gcc/c-family/c.opt
===================================================================
--- gcc/c-family/c.opt (revision 193124)
+++ gcc/c-family/c.opt (working copy)
@@ -1197,6 +1197,18 @@
C ObjC C++ ObjC++ Joined
-femit-struct-debug-detailed=<spec-list> Detailed reduced debug info for
structs
+fimaginary-literals
+C++ ObjC++
+Interpret imaginary number suffix as an imaginary number literal
+
+ffixed-point-literals
+C++ ObjC++
+Interpret fixed-point number suffix as a fixed-point number literal
+
+fmachine-defined-literals
+C++ ObjC++
+Interpret fixed-point number suffix as amachine-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
Index: gcc/cp/decl.c
===================================================================
--- gcc/cp/decl.c (revision 193124)
+++ gcc/cp/decl.c (working copy)
@@ -7519,13 +7519,13 @@
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);
}
Index: gcc/testsuite/g++.dg/cpp0x/fno-fixed-point-literals.C
===================================================================
--- gcc/testsuite/g++.dg/cpp0x/fno-fixed-point-literals.C (revision 0)
+++ gcc/testsuite/g++.dg/cpp0x/fno-fixed-point-literals.C (revision 0)
@@ -0,0 +1,115 @@
+// { dg-do compile }
+// { dg-options "-std=c++11 -fno-fixed-point-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)
+{ 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) // { 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;
+ 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 }
Index: gcc/testsuite/g++.dg/cpp0x/fno-imaginary-literals.C
===================================================================
--- gcc/testsuite/g++.dg/cpp0x/fno-imaginary-literals.C (revision 0)
+++ gcc/testsuite/g++.dg/cpp0x/fno-imaginary-literals.C (revision 0)
@@ -0,0 +1,115 @@
+// { dg-do compile }
+// { dg-options "-std=c++11 -fno-imaginary-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) // { 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 }
Index: gcc/testsuite/g++.dg/cpp0x/fno-machine-defined-literals.C
===================================================================
--- gcc/testsuite/g++.dg/cpp0x/fno-machine-defined-literals.C (revision 0)
+++ gcc/testsuite/g++.dg/cpp0x/fno-machine-defined-literals.C (revision 0)
@@ -0,0 +1,115 @@
+// { dg-do compile }
+// { dg-options "-std=c++11 -fno-machine-defined-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)
+{ 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; // { 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 }
Index: gcc/testsuite/g++.dg/cpp0x/ffixed-point-literals.C
===================================================================
--- gcc/testsuite/g++.dg/cpp0x/ffixed-point-literals.C (revision 0)
+++ gcc/testsuite/g++.dg/cpp0x/ffixed-point-literals.C (revision 0)
@@ -0,0 +1,115 @@
+// { dg-do compile }
+// { dg-options "-std=c++1y -ffixed-point-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) // { 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)
+{ 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; // { 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 }
Index: gcc/testsuite/g++.dg/cpp0x/fimaginary-literals.C
===================================================================
--- gcc/testsuite/g++.dg/cpp0x/fimaginary-literals.C (revision 0)
+++ gcc/testsuite/g++.dg/cpp0x/fimaginary-literals.C (revision 0)
@@ -0,0 +1,115 @@
+// { dg-do compile }
+// { dg-options "-std=c++1y -fimaginary-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)
+{ 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 }
Index: gcc/testsuite/g++.dg/cpp0x/fmachine-defined-literals.C
===================================================================
--- gcc/testsuite/g++.dg/cpp0x/fmachine-defined-literals.C (revision 0)
+++ gcc/testsuite/g++.dg/cpp0x/fmachine-defined-literals.C (revision 0)
@@ -0,0 +1,115 @@
+// { dg-do compile }
+// { dg-options "-std=c++1y -fmachine-defined-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) // { 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;
+ 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 }