re PR c++/84644 (internal compiler error: in warn_misplaced_attr_for_class_type,...
authorPaolo Carlini <paolo.carlini@oracle.com>
Sat, 15 Dec 2018 09:07:38 +0000 (09:07 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Sat, 15 Dec 2018 09:07:38 +0000 (09:07 +0000)
/cp
2018-12-15  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/84644
* decl.c (check_tag_decl): A decltype with no declarator
doesn't declare anything.

/testsuite
2018-12-15  Paolo Carlini  <paolo.carlini@oracle.com>

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

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/decltype-33838.C
gcc/testsuite/g++.dg/cpp0x/decltype68.C [new file with mode: 0644]
gcc/testsuite/g++.dg/template/spec32.C
gcc/testsuite/g++.dg/template/ttp22.C

index 2dfb1fed6130c5826b02b481fa4e68bfa011e7d1..ee9e570687b8ae0e7bba5a2b837b0d6c817a87b7 100644 (file)
@@ -1,3 +1,9 @@
+2018-12-15  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/84644
+       * decl.c (check_tag_decl): A decltype with no declarator
+       doesn't declare anything.
+
 2018-12-14  Alexandre Oliva <aoliva@redhat.com>
 
        PR c++/87814
index 5435ef2c8249c4d8819438930ad2e9dbd6b4faa0..d6028e3608c448e7bd8db683af5ae40f7220c18a 100644 (file)
@@ -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],
                "%<auto%> 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))
index bbc7e3fa4bcbbcff2bcbad4df67db305c3188e42..707d728bd29175b845da8890d561110812087dde 100644 (file)
@@ -1,3 +1,11 @@
+2018-12-15  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       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  <jakub@redhat.com>
 
        PR target/88489
index effe08dcc4bb44e300c6057173878b5ecc7742d6..43888da548a50210c8907ca78d905bad16e454ff 100644 (file)
@@ -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" }
 };
diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype68.C b/gcc/testsuite/g++.dg/cpp0x/decltype68.C
new file mode 100644 (file)
index 0000000..58740c1
--- /dev/null
@@ -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" }
+};
index 6ef172b505cc20e2307213ce6106b2994493cd8f..7cb3f40267643e77efbb245790539ea2892d2ca9 100644 (file)
@@ -2,5 +2,5 @@
 
 struct A
 {
-  template<template<int> class B> struct B<0>;  // { dg-error "name of class shadows" }
+  template<template<int> class B> struct B<0>;  // { dg-error "declaration does not declare anything" }
 };
index 08eaa30424643576abcaa22457567968f8d81c82..64aaf7437713565dc90f37365ba930d8296f9edf 100644 (file)
@@ -2,7 +2,7 @@
 // { dg-do compile }
 
 template<template<int> class A>
-class A<0>;  // { dg-error "shadows template template parameter" }
+class A<0>;  // { dg-error "declaration does not declare anything" }
 
 template<template<int> class B>
 class B<0> {};  // { dg-error "shadows template template parameter" }