From: Paolo Carlini Date: Sat, 15 Dec 2018 09:07:38 +0000 (+0000) Subject: re PR c++/84644 (internal compiler error: in warn_misplaced_attr_for_class_type,... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=1039d00c597ece034f51a66d085fa80f1f11d9e2;p=gcc.git re PR c++/84644 (internal compiler error: in warn_misplaced_attr_for_class_type, at cp/decl.c:4718) /cp 2018-12-15 Paolo Carlini PR c++/84644 * decl.c (check_tag_decl): A decltype with no declarator doesn't declare anything. /testsuite 2018-12-15 Paolo Carlini PR c++/84644 * g++.dg/cpp0x/decltype68.C: New. * g++.dg/cpp0x/decltype-33838.C: Adjust. * g++.dg/template/spec32.C: Likewise. * g++.dg/template/ttp22.C: Likewise. From-SVN: r267165 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 2dfb1fed613..ee9e570687b 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2018-12-15 Paolo Carlini + + PR c++/84644 + * decl.c (check_tag_decl): A decltype with no declarator + doesn't declare anything. + 2018-12-14 Alexandre Oliva PR c++/87814 diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 5435ef2c824..d6028e3608c 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -4803,15 +4803,20 @@ 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 " "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)) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index bbc7e3fa4bc..707d728bd29 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2018-12-15 Paolo Carlini + + PR c++/84644 + * g++.dg/cpp0x/decltype68.C: New. + * g++.dg/cpp0x/decltype-33838.C: Adjust. + * g++.dg/template/spec32.C: Likewise. + * g++.dg/template/ttp22.C: Likewise. + 2018-12-15 Jakub Jelinek PR target/88489 diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype-33838.C b/gcc/testsuite/g++.dg/cpp0x/decltype-33838.C index effe08dcc4b..43888da548a 100644 --- a/gcc/testsuite/g++.dg/cpp0x/decltype-33838.C +++ b/gcc/testsuite/g++.dg/cpp0x/decltype-33838.C @@ -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" } }; diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype68.C b/gcc/testsuite/g++.dg/cpp0x/decltype68.C new file mode 100644 index 00000000000..58740c1f10f --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/decltype68.C @@ -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" } +}; diff --git a/gcc/testsuite/g++.dg/template/spec32.C b/gcc/testsuite/g++.dg/template/spec32.C index 6ef172b505c..7cb3f402676 100644 --- a/gcc/testsuite/g++.dg/template/spec32.C +++ b/gcc/testsuite/g++.dg/template/spec32.C @@ -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" } }; diff --git a/gcc/testsuite/g++.dg/template/ttp22.C b/gcc/testsuite/g++.dg/template/ttp22.C index 08eaa304246..64aaf743771 100644 --- a/gcc/testsuite/g++.dg/template/ttp22.C +++ b/gcc/testsuite/g++.dg/template/ttp22.C @@ -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" }