diff mbox

2 C++ cleanup PATCHes

Message ID 55C2B8B8.20307@redhat.com
State New
Headers show

Commit Message

Jason Merrill Aug. 6, 2015, 1:30 a.m. UTC
1) While working on 66260, it struck me as odd that finish_id_expression 
had its own code for determining whether an id-expression is dependent, 
rather than using type_dependent_expression_p.  So this patch tears out 
a bunch of code and replaces it with a call; t_d_e_p already handled 
everything except a TEMPLATE_ID_EXPR with an IDENTIFIER_NODE as its lhs. 
  I also needed to tweak handling of CONST_DECLs so that we return them 
unchanged even if there is an explicit scope.

2) When we reject an explicit specialization because there is no 
template that matches it, it would be friendly to print a list of the 
candidates considered.

Tested x86_64-pc-linux-gnu, applying to trunk.
diff mbox

Patch

commit a54cb70add522cfa4c10cc1efc39108db7a7d60f
Author: Jason Merrill <jason@redhat.com>
Date:   Wed Aug 5 17:03:08 2015 -0400

    	* pt.c (determine_specialization): Print candidates after 'no
    	match' error.

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 5f28f1b..08fb2ff 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -1952,6 +1952,8 @@  determine_specialization (tree template_id,
        b = b->level_chain)
     ++header_count;
 
+  tree orig_fns = fns;
+
   if (variable_template_p (fns))
     {
       tree parms = INNERMOST_TEMPLATE_PARMS (DECL_TEMPLATE_PARMS (fns));
@@ -2168,6 +2170,8 @@  determine_specialization (tree template_id,
 	inform (input_location, "saw %d %<template<>%>, need %d for "
 		"specializing a member function template",
 		header_count, template_count + 1);
+      else
+	print_candidates (orig_fns);
       return error_mark_node;
     }
   else if ((templates && TREE_CHAIN (templates))
diff --git a/gcc/testsuite/g++.dg/template/spec39.C b/gcc/testsuite/g++.dg/template/spec39.C
new file mode 100644
index 0000000..9e4f8be
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/spec39.C
@@ -0,0 +1,3 @@ 
+template <class T> void f(T);	// { dg-message "void f" }
+template <> int f(int);		// { dg-error "does not match" }
+