This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/68842] Better error output when template needed before dependent name


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68842

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -4907,8 +4907,13 @@ cp_build_binary_op (location_t location,
   if (!result_type)
     {
       if (complain & tf_error)
-       error ("invalid operands of types %qT and %qT to binary %qO",
-              TREE_TYPE (orig_op0), TREE_TYPE (orig_op1), code);
+        {
+          error ("invalid operands of types %qT and %qT to binary %qO",
+                 TREE_TYPE (orig_op0), TREE_TYPE (orig_op1), code);
+          if (code == LT_EXPR)
+            inform (input_location, "use the keyword %<template%> before the "
+                    "name of a member template belonging to a dependent
type");
+        }
       return error_mark_node;
     }

This patch adds the following line after the error:

tt.cc:15:15: note: use the keyword âtemplateâ before the name of a member
template belonging to a dependent type

I don't know how to make it only issue that note when the LHS is one of
foo.bar, foo->bar, or foo::bar.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]