This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/68842] Better error output when template needed before dependent name
- From: "redi at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 11 Dec 2015 12:57:25 +0000
- Subject: [Bug c++/68842] Better error output when template needed before dependent name
- Auto-submitted: auto-generated
- References: <bug-68842-4 at http dot gcc dot gnu dot org/bugzilla/>
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.