}
if (!start_function (specs, declarator, all_prefix_attrs))
{
- /* This can appear in many cases looking nothing like a
- function definition, so we don't give a more specific
- error suggesting there was one. */
- c_parser_error (parser, "expected %<=%>, %<,%>, %<;%>, %<asm%> "
- "or %<__attribute__%>");
+ /* At this point we've consumed:
+ declaration-specifiers declarator
+ and the next token isn't CPP_EQ, CPP_COMMA, CPP_SEMICOLON,
+ RID_ASM, RID_ATTRIBUTE, or RID_IN,
+ but the
+ declaration-specifiers declarator
+ aren't grokkable as a function definition, so we have
+ an error. */
+ gcc_assert (!c_parser_next_token_is (parser, CPP_SEMICOLON));
+ if (c_parser_next_token_starts_declspecs (parser))
+ {
+ /* If we have
+ declaration-specifiers declarator decl-specs
+ then assume we have a missing semicolon, which would
+ give us:
+ declaration-specifiers declarator decl-specs
+ ^
+ ;
+ <~~~~~~~~~ declaration ~~~~~~~~~~>
+ Use c_parser_require to get an error with a fix-it hint. */
+ c_parser_require (parser, CPP_SEMICOLON, "expected %<;%>");
+ parser->error = false;
+ }
+ else
+ {
+ /* This can appear in many cases looking nothing like a
+ function definition, so we don't give a more specific
+ error suggesting there was one. */
+ c_parser_error (parser, "expected %<=%>, %<,%>, %<;%>, %<asm%> "
+ "or %<__attribute__%>");
+ }
if (nested)
c_pop_function_context ();
break;
+2017-10-25 David Malcolm <dmalcolm@redhat.com>
+
+ PR c/7356
+ PR c/44515
+ * c-c++-common/pr44515.c: New test case.
+ * gcc.dg/pr7356-2.c: New test case.
+ * gcc.dg/pr7356.c: New test case.
+ * gcc.dg/spellcheck-typenames.c: Update the "singed" char "TODO"
+ case to reflect changes to output.
+ * gcc.dg/noncompile/920923-1.c: Add dg-warning to reflect changes
+ to output.
+
2017-10-25 Eric Botcazou <ebotcazou@adacore.com>
* gcc.dg/fold-cond_expr-1.c: Rename to...
--- /dev/null
+/* { dg-options "-fdiagnostics-show-caret" } */
+
+int i /* { dg-error "6: expected ';' before 'int'" } */
+int j;
+/* { dg-begin-multiline-output "" }
+ int i
+ ^
+ ;
+ int j;
+ ~~~
+ { dg-end-multiline-output "" } */
+
+
+void test (void)
+{
+ int i /* { dg-error "8: expected ';' before 'int'" } */
+ int j;
+
+ /* { dg-begin-multiline-output "" }
+ int i
+ ^
+ ;
+ int j;
+ ~~~
+ { dg-end-multiline-output "" } */
+}
+
+int old_style_params (first, second)
+ int first;
+ int second;
+{
+ return first + second;
+}
--- /dev/null
+/* { dg-options "-fdiagnostics-show-caret" } */
+
+a /* { dg-line stray_token } */
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+int main(int argc, char** argv)
+{
+ return 0;
+}
+
+/* { dg-error "expected ';' before '.*'" "" { target *-*-* } stray_token } */
+/* { dg-begin-multiline-output "" }
+ a
+ ^
+ ;
+ { dg-end-multiline-output "" } */