re PR c++/65923 (False positive for warning about literal operator suffix and using)
authorVille Voutilainen <ville.voutilainen@gmail.com>
Wed, 4 Apr 2018 16:05:11 +0000 (19:05 +0300)
committerVille Voutilainen <ville@gcc.gnu.org>
Wed, 4 Apr 2018 16:05:11 +0000 (19:05 +0300)
PR c++/65923

gcc/cp

PR c++/65923
* decl.c (grokfndecl): Handle standard UDL diagnostics here..
* parser.c (cp_parser_unqualified_id): ..not here.

testsuite/

PR c++/65923
* g++.dg/diagnostic/pr65923.C: New.

From-SVN: r259087

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/cp/parser.c
gcc/testsuite/g++.dg/diagnostic/pr65923.C [new file with mode: 0644]

index 46f05c8661e28df589e1f00d632a2a5269b3b86d..0c71d2bd9de82ebde17885109192663e9a149bc5 100644 (file)
@@ -1,3 +1,9 @@
+2018-04-04  Ville Voutilainen  <ville.voutilainen@gmail.com>
+
+       PR c++/65923
+       * decl.c (grokfndecl): Handle standard UDL diagnostics here..
+       * parser.c (cp_parser_unqualified_id): ..not here.
+
 2018-04-04  Alexandre Oliva <aoliva@redhat.com>
 
        PR c++/84943
index 6ddbe2343f4870be2fac5aaa88adf05b101c1e38..c8ae72faeae13d159969bb91563a3fc5241bc037 100644 (file)
@@ -8944,6 +8944,13 @@ grokfndecl (tree ctype,
                warning (0, "floating point suffix %qs"
                            " shadowed by implementation", suffix);
            }
+         /* 17.6.3.3.5  */
+         if (suffix[0] != '_'
+             && !in_system_header_at (DECL_SOURCE_LOCATION (decl))
+             && !current_function_decl && !(friendp && !funcdef_flag))
+           warning (OPT_Wliteral_suffix,
+                    "literal operator suffixes not preceded by %<_%>"
+                    " are reserved for future standardization");
        }
       else
        {
index d526a4eb3652e9e3e399c69bea0b8728bf3fa17d..f6fbcf6185e4cd6f5dbf804cfa566fbdc2f3952a 100644 (file)
@@ -6100,16 +6100,6 @@ cp_parser_unqualified_id (cp_parser* parser,
          /* If that didn't work, try a conversion-function-id.  */
          if (!cp_parser_parse_definitely (parser))
            id = cp_parser_conversion_function_id (parser);
-         else if (UDLIT_OPER_P (id))
-           {
-             /* 17.6.3.3.5  */
-             const char *name = UDLIT_OP_SUFFIX (id);
-             if (name[0] != '_' && !in_system_header_at (input_location)
-                 && declarator_p)
-               warning (OPT_Wliteral_suffix,
-                        "literal operator suffixes not preceded by %<_%>"
-                        " are reserved for future standardization");
-           }
 
          return id;
        }
diff --git a/gcc/testsuite/g++.dg/diagnostic/pr65923.C b/gcc/testsuite/g++.dg/diagnostic/pr65923.C
new file mode 100644 (file)
index 0000000..036f447
--- /dev/null
@@ -0,0 +1,23 @@
+// { dg-do compile { target c++14 } }
+
+#include <chrono>
+
+using std::literals::chrono_literals::operator""s;
+
+struct X
+{
+  friend constexpr std::chrono::duration<long double> std::literals::chrono_literals::operator""s(long double);
+};
+
+struct X2
+{
+  friend constexpr X operator""foo(long double) {return {};} // { dg-warning "literal operator suffixes not preceded" }
+};
+
+namespace std
+{
+  template<> void swap(X&, X&)
+  {
+    constexpr std::chrono::duration<long double> operator""s(long double);
+  }
+}