Mercurial > ~dholland > hg > ag > index.cgi
view tests/agcl/bugs/wraperror.syn @ 8:ec2b657edf13
Add explicit lint-comment-style fallthrough annotations.
GCC now assumes that if you don't have these you're making a mistake,
which is annoying.
XXX: This changeset updates the AG output files only (by hand) and is
XXX: abusive - rebuilding them will erase the change. However, I need
XXX: to get things to build before I can try to get AG to issue the
XXX: annotations itself, so this seems like a reasonable expedient.
author | David A. Holland |
---|---|
date | Mon, 30 May 2022 23:51:43 -0400 |
parents | 13d2b8934445 |
children |
line wrap: on
line source
{ /* * AnaGram, A System for Syntax Directed Programming * Copyright 2006 David A. Holland. All Rights Reserved. * See the file COPYING for license and usage terms. * * wraperror: test for wrappers and error token together */ #include <stdio.h> struct thingy { const char *name; int val; void g(const char *n, int v) { name = n; val = v; } void g(const thingy &t) { name = t.name; val = t.val; } void m(const char *msg) { printf("%s %s: %p, %d\n", msg, name, this, val); } thingy(const char *n, int v) { g(n,v); m("Constructed new"); } thingy(const thingy &t) { g(t); m("Copied"); } void operator = (const thingy &t) { g(t); m("Assigned"); } ~thingy() { m("Destroyed"); } }; struct foo : public thingy { foo(int v) : thingy("foo", v) {} foo(const foo &f) : thingy(f) {} void operator = (const foo &f) { thingy::operator = (f); } ~foo() {} }; struct bar : public thingy { bar(int v) : thingy("bar", v) {} bar(const bar &f) : thingy(f) {} void operator = (const bar &f) { thingy::operator = (f); } ~bar() {} }; void do_foo(foo &f) { f.m("do_foo"); } void do_bar(bar &b) { b.m("do_bar"); } } [ parser file name = "#.cpp" wrapper { foo } ] file $ -> declarations, eof declarations -> declaration... declaration -> foo decl:f, '\n' = do_foo(f); -> bar decl:b, '\n' = do_bar(b); -> '\n' -> error (foo) foo decl -> 'f', 'o', 'o' = foo(1); (bar) bar decl -> 'b', 'a', 'r' = bar(2); eof = 0 { int main() { wraperror(); return 0; } }