This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [C++ Patch] Fix for PR c++/19076 and PR c++/6628

On Feb 21, 2005, at 7:08 PM, Gabriel Dos Reis wrote:

Douglas Gregor <> writes:


| However, one cannot add qualifiers to a function type. For instance,
| the second line of the following code does not add qualifiers to
| "foo":
|   typedef int foo(float) const;
|   typedef volatile foo foo_v; // #2

GCC has an extension whereby

volatile foo F;

is legal and means that "F" cannot return.  How does your patch
interact with that extension?

Does this extension work in G++? I tried this little program:

  typedef void voidfn();
  volatile voidfn fatal;

  void fatal()

I expected that this would result in a warning saying that "fatal" was marked noreturn but has a return statement. However:

On GCC & G++ 3.3.5, I get the error '`volatile' qualifiers cannot be applied to `void ()()'.
On G++ mainline (before the patch), I get nothing. The function doesn't seem to be marked noreturn by this code.
On G++ mainline (after my patch), I get nothing. However, if I add "-pedantic", I get an error saying that volatile qualifiers can't be added.
On GCC mainline (before and after), I get nothing.

Now, if I use the noreturn attribute, then I always get the "function declared noreturn has a return statement" warning, regardless of the compiler.

So AFAICT, this functionality was broken in 3.3.5 and is broken in mainline CVS. This patch ends up introducing an error message on "-pedantic". Perhaps everyone has already migrated to noreturn, so nobody noticed that this extension no longer works?


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]