+2019-01-07 Joseph Myers <joseph@codesourcery.com>
+
+ PR c/88720
+ PR c/88726
+ * c-decl.c (pop_scope): Use TREE_PUBLIC and b->nested to determine
+ whether a function is nested, not DECL_EXTERNAL. Diagnose inline
+ functions declared but never defined only for external scope, not
+ for other scopes.
+
2019-01-07 Jakub Jelinek <jakub@redhat.com>
PR c++/85052
&& DECL_ABSTRACT_ORIGIN (p) != NULL_TREE
&& DECL_ABSTRACT_ORIGIN (p) != p)
TREE_ADDRESSABLE (DECL_ABSTRACT_ORIGIN (p)) = 1;
- if (!DECL_EXTERNAL (p)
+ if (!TREE_PUBLIC (p)
&& !DECL_INITIAL (p)
+ && !b->nested
&& scope != file_scope
&& scope != external_scope)
{
in the same translation unit." */
if (!flag_gnu89_inline
&& !lookup_attribute ("gnu_inline", DECL_ATTRIBUTES (p))
- && scope != external_scope)
+ && scope == external_scope)
pedwarn (input_location, 0,
"inline function %q+D declared but never defined", p);
DECL_EXTERNAL (p) = 1;
+2019-01-07 Joseph Myers <joseph@codesourcery.com>
+
+ PR c/88720
+ PR c/88726
+ * gcc.dg/inline-40.c, gcc.dg/inline-41.c: New tests.
+
2019-01-07 Paolo Carlini <paolo.carlini@oracle.com>
* g++.dg/diagnostic/constexpr1.C: New.
--- /dev/null
+/* Test inline functions declared in inner scopes. Bugs 88720 and 88726. */
+/* { dg-do compile } */
+/* { dg-options "" } */
+
+void
+inline_1 (void)
+{
+}
+
+void
+inline_2 (void)
+{
+}
+
+static void
+inline_static_1 (void)
+{
+}
+
+static void
+inline_static_2 (void)
+{
+}
+
+static void inline_static_3 (void);
+static void inline_static_4 (void);
+
+static void
+test (void)
+{
+ inline void inline_1 (void);
+ extern inline void inline_2 (void);
+ inline void inline_3 (void);
+ extern inline void inline_4 (void);
+ inline void inline_static_1 (void);
+ extern inline void inline_static_2 (void);
+ inline void inline_static_3 (void);
+ extern inline void inline_static_4 (void);
+}
+
+void
+inline_3 (void)
+{
+}
+
+void
+inline_4 (void)
+{
+}
--- /dev/null
+/* Test inline functions declared in inner scopes. Bugs 88720 and 88726. */
+/* { dg-do compile } */
+/* { dg-options "-fgnu89-inline" } */
+
+void
+inline_1 (void)
+{
+}
+
+void
+inline_2 (void)
+{
+}
+
+static void
+inline_static_1 (void)
+{
+}
+
+static void
+inline_static_2 (void)
+{
+}
+
+static void inline_static_3 (void);
+static void inline_static_4 (void);
+
+static void
+test (void)
+{
+ inline void inline_1 (void);
+ extern inline void inline_2 (void);
+ inline void inline_3 (void);
+ extern inline void inline_4 (void);
+ inline void inline_static_1 (void);
+ extern inline void inline_static_2 (void);
+ inline void inline_static_3 (void);
+ extern inline void inline_static_4 (void);
+}
+
+void
+inline_3 (void)
+{
+}
+
+void
+inline_4 (void)
+{
+}