]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/77812 (incorrectly rejects valid C++ code that uses enum in template instan...
authorNathan Sidwell <nathan@acm.org>
Thu, 12 Jan 2017 12:40:28 +0000 (12:40 +0000)
committerNathan Sidwell <nathan@gcc.gnu.org>
Thu, 12 Jan 2017 12:40:28 +0000 (12:40 +0000)
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

gcc/cp/ChangeLog
gcc/cp/name-lookup.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/pr77812.C [new file with mode: 0644]

index 0fbbe2118bae13439d68224ad85b59b07b52c4ff..8a89f21051b009afdb604659cc7c575e3a78c2b8 100644 (file)
@@ -1,3 +1,9 @@
+2017-01-12  Nathan Sidwell  <nathan@acm.org>
+
+       PR c++/77812
+       * name-lookup.c (set_namespace_binding_1): An overload of 1 decl
+       is a new overload.
+
 2016-12-08  Nathan Sidwell  <nathan@acm.org>
 
        PR c++/78551
index 9e4e0e3adf5712098705d6e080296eb72f8b532b..5c8d189e4ff23ba07cc8eb190a2117dfa00bc064 100644 (file)
@@ -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);
index d400de17da8200bdf541e179a401dda0f052dbfe..0b7c3da7d5ab892251cde792d635ae01d76ab26f 100644 (file)
@@ -1,3 +1,8 @@
+2017-01-12  Nathan Sidwell  <nathan@acm.org>
+
+       PR c++/77812
+       * g++.dg/pr77812.C: New.
+
 2017-01-11  Andre Vieira <andre.simoesdiasvieira@arm.com>
 
        Backport from mainline
diff --git a/gcc/testsuite/g++.dg/pr77812.C b/gcc/testsuite/g++.dg/pr77812.C
new file mode 100644 (file)
index 0000000..94f1740
--- /dev/null
@@ -0,0 +1,18 @@
+// PR77812
+// struct-stat hack failure when first overload is a template
+
+enum f {};
+
+template <typename>
+void f ()
+{
+}
+enum f F;
+
+struct g {};
+
+template <typename>
+void g ()
+{
+}
+struct g G;