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 21784


This patch fixes PR c++/21784, a problem with using declarations and
builtin functions.  (As I've said before, it's a design bug that we
create builtin FUNCTION_DECLs before we need them in C++; it's just
asking for trouble, as we must always remember to check
DECL_ANTICIPATED to see whether or not a function is "really there".)

Tested on x86_64-unknown-linux-gnu, applied on the mainline and on the
4.0 branch.

--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com

2005-05-30  Mark Mitchell  <mark@codesourcery.com>

	PR c++/21784
	* name-lookup.c (do_nonmember_using_decl): Ignore builtin
	functions, even	when the used name is not a function.

2005-05-29  Mark Mitchell  <mark@codesourcery.com>

	PR c++/21784
	* g++.dg/lookup/using14.C: New test.

Index: gcc/cp/name-lookup.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/name-lookup.c,v
retrieving revision 1.120
diff -c -5 -p -r1.120 name-lookup.c
*** gcc/cp/name-lookup.c	25 May 2005 04:17:36 -0000	1.120
--- gcc/cp/name-lookup.c	30 May 2005 02:33:21 -0000
*************** do_nonmember_using_decl (tree scope, tre
*** 2030,2039 ****
--- 2030,2047 ----
      {
        error ("%qD not declared", name);
        return;
      }
  
+   /* It is impossible to overload a built-in function; any explicit
+      declaration eliminates the built-in declaration.  So, if OLDVAL
+      is a built-in, then we can just pretend it isn't there.  */
+   if (oldval 
+       && TREE_CODE (oldval) == FUNCTION_DECL
+       && DECL_ANTICIPATED (oldval))
+     oldval = NULL_TREE;
+ 
    /* Check for using functions.  */
    if (decls.value && is_overloaded_fn (decls.value))
      {
        tree tmp, tmp1;
  
*************** do_nonmember_using_decl (tree scope, tre
*** 2042,2060 ****
  	  if (!DECL_IMPLICIT_TYPEDEF_P (oldval))
  	    error ("%qD is already declared in this scope", name);
  	  oldval = NULL_TREE;
  	}
  
-       /* It is impossible to overload a built-in function; any
- 	 explicit declaration eliminates the built-in declaration.
- 	 So, if OLDVAL is a built-in, then we can just pretend it
- 	 isn't there.  */
-       if (oldval 
- 	  && TREE_CODE (oldval) == FUNCTION_DECL
- 	  && DECL_ANTICIPATED (oldval))
- 	oldval = NULL_TREE;
- 
        *newval = oldval;
        for (tmp = decls.value; tmp; tmp = OVL_NEXT (tmp))
  	{
  	  tree new_fn = OVL_CURRENT (tmp);
  
--- 2050,2059 ----
Index: gcc/testsuite/g++.dg/lookup/using14.C
===================================================================
RCS file: gcc/testsuite/g++.dg/lookup/using14.C
diff -N gcc/testsuite/g++.dg/lookup/using14.C
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- gcc/testsuite/g++.dg/lookup/using14.C	30 May 2005 02:33:21 -0000
***************
*** 0 ****
--- 1,9 ----
+ // PR c++/21784
+ // { dg-options "" }
+ 
+ namespace mine
+ {
+   int cpow;
+ }
+ 
+ using mine::cpow;


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