From: Nathan Sidwell Date: Thu, 12 Jan 2017 12:40:28 +0000 (+0000) Subject: re PR c++/77812 (incorrectly rejects valid C++ code that uses enum in template instan... X-Git-Tag: releases/gcc-5.5.0~591 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=35995667c3eefd0332fdfc57b0c69dd31b89a0b3;p=thirdparty%2Fgcc.git re PR c++/77812 (incorrectly rejects valid C++ code that uses enum in template instantiation) cp/ PR c++/77812 * name-lookup.c (set_namespace_binding_1): An overload of 1 decl is a new overload. testsuite/ PR c++/77812 * g++.dg/pr77812.C: New. From-SVN: r244351 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 0fbbe2118bae..8a89f21051b0 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2017-01-12 Nathan Sidwell + + PR c++/77812 + * name-lookup.c (set_namespace_binding_1): An overload of 1 decl + is a new overload. + 2016-12-08 Nathan Sidwell PR c++/78551 diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c index 9e4e0e3adf57..5c8d189e4ff2 100644 --- a/gcc/cp/name-lookup.c +++ b/gcc/cp/name-lookup.c @@ -3477,7 +3477,12 @@ set_namespace_binding_1 (tree name, tree scope, tree val) if (scope == NULL_TREE) scope = global_namespace; b = binding_for_name (NAMESPACE_LEVEL (scope), name); - if (!b->value || TREE_CODE (val) == OVERLOAD || val == error_mark_node) + if (!b->value + /* For templates and using we create a single element OVERLOAD. + Look for the chain to know whether this is really augmenting + an existing overload. */ + || (TREE_CODE (val) == OVERLOAD && OVL_CHAIN (val)) + || val == error_mark_node) b->value = val; else supplement_binding (b, val); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d400de17da82..0b7c3da7d5ab 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-01-12 Nathan Sidwell + + PR c++/77812 + * g++.dg/pr77812.C: New. + 2017-01-11 Andre Vieira Backport from mainline diff --git a/gcc/testsuite/g++.dg/pr77812.C b/gcc/testsuite/g++.dg/pr77812.C new file mode 100644 index 000000000000..94f17402a4e1 --- /dev/null +++ b/gcc/testsuite/g++.dg/pr77812.C @@ -0,0 +1,18 @@ +// PR77812 +// struct-stat hack failure when first overload is a template + +enum f {}; + +template +void f () +{ +} +enum f F; + +struct g {}; + +template +void g () +{ +} +struct g G;