This is the mail archive of the gcc-patches@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]

[C++ Patch] PR 35075


Hi,

another small issue, a P4, where without checking only the error message
is garbled.

Tested x86_64-linux. Ok for mainline?

Paolo.

//////////////////////
/cp
2009-02-02  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/35075
	* pt.c (convert_nontype_argument): Do not call DECL_EXTERNAL_LINKAGE_P
	on non-decl.
	* error.c (dump_decl): Handle INDIRECT_REF.

/testsuite
2009-02-02  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/35075
	* g++.dg/template/crash88.C: New.
Index: testsuite/g++.dg/template/crash88.C
===================================================================
*** testsuite/g++.dg/template/crash88.C	(revision 0)
--- testsuite/g++.dg/template/crash88.C	(revision 0)
***************
*** 0 ****
--- 1,11 ----
+ // PR c++/35075
+ 
+ template<int&> struct A {};
+ 
+ template<typename T> struct B
+ {
+   static const T t;
+   A<t> a;  // { dg-error "not a valid template argument" }
+ };
+ 
+ B<int&> b;
Index: cp/error.c
===================================================================
*** cp/error.c	(revision 143860)
--- cp/error.c	(working copy)
*************** dump_decl (tree t, int flags)
*** 972,977 ****
--- 972,978 ----
        break;
  
      case NON_DEPENDENT_EXPR:
+     case INDIRECT_REF:
        dump_expr (t, flags);
        break;
  
Index: cp/pt.c
===================================================================
*** cp/pt.c	(revision 143860)
--- cp/pt.c	(working copy)
*************** convert_nontype_argument (tree type, tre
*** 4535,4541 ****
  	 shall be one of: [...]
  
  	 -- the address of an object or function with external linkage.  */
!       if (!DECL_EXTERNAL_LINKAGE_P (expr))
  	{
  	  error ("%qE is not a valid template argument for type %qT "
  		 "because object %qD has not external linkage",
--- 4535,4541 ----
  	 shall be one of: [...]
  
  	 -- the address of an object or function with external linkage.  */
!       if (!DECL_P (expr) || !DECL_EXTERNAL_LINKAGE_P (expr))
  	{
  	  error ("%qE is not a valid template argument for type %qT "
  		 "because object %qD has not external linkage",

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