Hi,
here we ICE when, at the end of check_tag_decl we pass a DECLTYPE_TYPE
to warn_misplaced_attr_for_class_type. I think the right fix is
rejecting earlier a decltype with no declarator as a declaration that
doesn't declare anything (note: all the compilers I have at hand agree).
Tested x86_64-linux.
Thanks, Paolo.
////////////////////
/cp
2018-10-15 Paolo Carlini <[email protected]>
PR c++/84644
* decl.c (check_tag_decl): A decltype with no declarator
doesn't declare anything.
/testsuite
2018-10-15 Paolo Carlini <[email protected]>
PR c++/84644
* g++.dg/cpp0x/decltype68.C: New.
* g++.dg/cpp0x/decltype-33838.C: Adjust.Index: cp/decl.c
===================================================================
--- cp/decl.c (revision 265158)
+++ cp/decl.c (working copy)
@@ -4793,6 +4793,7 @@ check_tag_decl (cp_decl_specifier_seq *declspecs,
if (declspecs->type
&& TYPE_P (declspecs->type)
&& ((TREE_CODE (declspecs->type) != TYPENAME_TYPE
+ && TREE_CODE (declspecs->type) != DECLTYPE_TYPE
&& MAYBE_CLASS_TYPE_P (declspecs->type))
|| TREE_CODE (declspecs->type) == ENUMERAL_TYPE))
declared_type = declspecs->type;
Index: testsuite/g++.dg/cpp0x/decltype-33838.C
===================================================================
--- testsuite/g++.dg/cpp0x/decltype-33838.C (revision 265158)
+++ testsuite/g++.dg/cpp0x/decltype-33838.C (working copy)
@@ -2,5 +2,5 @@
// PR c++/33838
template<typename T> 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<int a>
+struct b {
+ decltype(a) __attribute__((break)); // { dg-error "declaration does not
declare anything" }
+};