On 07/12/2011 04:56 PM, Jason Merrill wrote:
A few more notes:
+ if (DECL_NAMESPACE_SCOPE_P (decl))
+ {
+ if (!check_literal_operator_args(decl,
+ &long_long_unsigned_p, &long_double_p))
+ {
+ error ("%qD has illegal argument list", decl);
+ return NULL_TREE;
+ }
+
+ if (CP_DECL_CONTEXT (decl) == global_namespace)
+ {
+ const char *suffix = UDLIT_OP_SUFFIX (DECL_NAME (decl));
+ if (long_long_unsigned_p)
+ {
+ if (cpp_interpret_int_suffix (suffix, strlen
(suffix)))
+ warning (0, "integer suffix shadowed by
implementation");
+ }
+ else if (long_double_p)
+ {
+ if (cpp_interpret_float_suffix (suffix, strlen
(suffix)))
+ warning (0, "floating point suffix"
+ " shadowed by implementation");
+ }
+ }
+ }
Doesn't the shadowing apply everywhere, not just at file scope?
+ if (cpp_userdef_string_p (tok->type))
+ {
+ string_tree = USERDEF_LITERAL_VALUE (tok->u.value);
+ tok->type = cpp_userdef_string_remove_type (tok->type);
+ curr_tok_is_userdef_p = true;
+ }
It seems like a mistake to change tok->type without changing the
value. Why not just set the 'type' local variable appropriately?
+ const char *curr_suffix = IDENTIFIER_POINTER (suffix_id);
+ if (have_suffix_p == 0)
+ {
+ suffix = xstrdup (curr_suffix);
+ have_suffix_p = 1;
+ }
+ else if (have_suffix_p == 1 && strcmp (suffix,
curr_suffix) != 0)
...
+ USERDEF_LITERAL_SUFFIX_ID (literal) = get_identifier (suffix);
Just remember the identifier and compare it with ==. Identifiers are
unique.
+ /* Lookup the name we got back from the id-expression. */
+ decl = cp_parser_lookup_name (parser, name,
Maybe use lookup_function_nonclass?
Jason
I was conflating shadowing because of the preprocessor capturing
suffixed like F for float and L for long int, etc. (which are captured
by te preprocessor for those purposes) with allowing two user-specified
suffixes to be disambiguated with namespaces and using declarations as
mentioned in the paper.
I removed those tests.
Now I have a real question: Since a shadowed suffix *cannot* act like
the user wants no matter what, should I error instead of warn?