Index: cp/decl.c =================================================================== --- cp/decl.c (revision 267131) +++ cp/decl.c (working copy) @@ -4803,9 +4803,8 @@ check_tag_decl (cp_decl_specifier_seq *declspecs, declared_type = declspecs->type; else if (declspecs->type == error_mark_node) error_p = true; - if (declared_type == NULL_TREE && ! saw_friend && !error_p) - permerror (input_location, "declaration does not declare anything"); - else if (declared_type != NULL_TREE && type_uses_auto (declared_type)) + + if (type_uses_auto (declared_type)) { error_at (declspecs->locations[ds_type_spec], "% can only be specified for variables " @@ -4812,6 +4811,12 @@ check_tag_decl (cp_decl_specifier_seq *declspecs, "or function declarations"); return error_mark_node; } + + if (declared_type && !OVERLOAD_TYPE_P (declared_type)) + declared_type = NULL_TREE; + + if (!declared_type && !saw_friend && !error_p) + permerror (input_location, "declaration does not declare anything"); /* Check for an anonymous union. */ else if (declared_type && RECORD_OR_UNION_CODE_P (TREE_CODE (declared_type)) && TYPE_UNNAMED_P (declared_type)) Index: testsuite/g++.dg/cpp0x/decltype-33838.C =================================================================== --- testsuite/g++.dg/cpp0x/decltype-33838.C (revision 267127) +++ testsuite/g++.dg/cpp0x/decltype-33838.C (working copy) @@ -2,5 +2,5 @@ // PR c++/33838 template struct A { - __decltype (T* foo()); // { dg-error "expected|no arguments|accept" } + __decltype (T* foo()); // { dg-error "expected|no arguments|declaration" } }; Index: testsuite/g++.dg/cpp0x/decltype68.C =================================================================== --- testsuite/g++.dg/cpp0x/decltype68.C (nonexistent) +++ testsuite/g++.dg/cpp0x/decltype68.C (working copy) @@ -0,0 +1,7 @@ +// PR c++/84644 +// { dg-do compile { target c++11 } } + +template +struct b { + decltype(a) __attribute__((break)); // { dg-error "declaration does not declare anything" } +}; Index: testsuite/g++.dg/template/spec32.C =================================================================== --- testsuite/g++.dg/template/spec32.C (revision 267127) +++ testsuite/g++.dg/template/spec32.C (working copy) @@ -2,5 +2,5 @@ struct A { - template class B> struct B<0>; // { dg-error "name of class shadows" } + template class B> struct B<0>; // { dg-error "declaration does not declare anything" } }; Index: testsuite/g++.dg/template/ttp22.C =================================================================== --- testsuite/g++.dg/template/ttp22.C (revision 267127) +++ testsuite/g++.dg/template/ttp22.C (working copy) @@ -2,7 +2,7 @@ // { dg-do compile } template class A> -class A<0>; // { dg-error "shadows template template parameter" } +class A<0>; // { dg-error "declaration does not declare anything" } template class B> class B<0> {}; // { dg-error "shadows template template parameter" }