[cfe-commits] r112482 - in /cfe/trunk: lib/Sema/SemaExceptionSpec.cpp test/SemaCXX/MicrosoftExtensions.cpp test/SemaCXX/exception-spec.cpp

Michael Spencer bigcheesegs at gmail.com
Mon Aug 30 11:46:54 PDT 2010


On Mon, Aug 30, 2010 at 11:04 AM, Douglas Gregor <dgregor at apple.com> wrote:
> Author: dgregor
> Date: Mon Aug 30 10:04:51 2010
> New Revision: 112482
>
> URL: http://llvm.org/viewvc/llvm-project?rev=112482&view=rev
> Log:
> Emulate (some of) Microsoft's looser semantic checking of exception
> specifications, from Martin Vejnar!
>
>
> Modified:
>    cfe/trunk/lib/Sema/SemaExceptionSpec.cpp
>    cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp
>    cfe/trunk/test/SemaCXX/exception-spec.cpp
>
> Modified: cfe/trunk/lib/Sema/SemaExceptionSpec.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExceptionSpec.cpp?rev=112482&r1=112481&r2=112482&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Sema/SemaExceptionSpec.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaExceptionSpec.cpp Mon Aug 30 10:04:51 2010
> @@ -261,6 +261,14 @@
>
>   bool OldAny = !Old->hasExceptionSpec() || Old->hasAnyExceptionSpec();
>   bool NewAny = !New->hasExceptionSpec() || New->hasAnyExceptionSpec();
> +  if (getLangOptions().Microsoft) {
> +    // Treat throw(whatever) as throw(...) to be compatible with MS headers.
> +    if (New->hasExceptionSpec() && New->getNumExceptions() > 0)
> +      NewAny = true;
> +    if (Old->hasExceptionSpec() && Old->getNumExceptions() > 0)
> +      OldAny = true;
> +  }

I really don't like accepting bugs without any warnings. Clang should
complain if it ever sees this in anything but a Windows Platform
header (or macro expanded from such).

- Michael Spencer

>   if (OldAny && NewAny)
>     return false;
>   if (OldAny || NewAny) {
>
> Modified: cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp?rev=112482&r1=112481&r2=112482&view=diff
> ==============================================================================
> --- cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp (original)
> +++ cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp Mon Aug 30 10:04:51 2010
> @@ -1,7 +1,31 @@
> -// RUN: %clang_cc1 %s -fsyntax-only -verify -fms-extensions
> +// RUN: %clang_cc1 %s -fsyntax-only -verify -fms-extensions -fexceptions
>
>
>  // ::type_info is predeclared with forward class declartion
>  void f(const type_info &a);
>
> +// The following three are all equivalent when ms-extensions are on
> +void foo() throw(int);
> +void foo() throw(int, long);
> +void foo() throw(...);
> +void foo(); // expected-note {{previous declaration}}
>
> +// Only nothrow specification is treated specially.
> +void foo() throw(); // expected-error {{exception specification in declaration does not match previous declaration}}
> +
> +// throw(...)
> +void r3();
> +void r3() throw(...);
> +
> +void r6() throw(...);
> +void r6() throw(int); // okay
> +
> +struct Base {
> +  virtual void f2();
> +  virtual void f3() throw(...);
> +};
> +
> +struct Derived : Base {
> +  virtual void f2() throw(...);
> +  virtual void f3();
> +};
>
> Modified: cfe/trunk/test/SemaCXX/exception-spec.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/exception-spec.cpp?rev=112482&r1=112481&r2=112482&view=diff
> ==============================================================================
> --- cfe/trunk/test/SemaCXX/exception-spec.cpp (original)
> +++ cfe/trunk/test/SemaCXX/exception-spec.cpp Mon Aug 30 10:04:51 2010
> @@ -1,4 +1,4 @@
> -// RUN: %clang_cc1 -fsyntax-only -verify -fexceptions -fms-extensions %s
> +// RUN: %clang_cc1 -fsyntax-only -verify -fexceptions %s
>
>  // Straight from the standard:
>  // Plain function with spec
> @@ -43,18 +43,12 @@
>  void r2() throw(INT);
>
>  // throw-any spec and no spec at all are semantically equivalent
> -void r3();
> -void r3() throw(...);
> -
>  void r4() throw(int, float);
>  void r4() throw(float, int);
>
>  void r5() throw(int); // expected-note {{previous declaration}}
>  void r5(); // expected-warning {{missing exception specification}}
>
> -void r6() throw(...); // expected-note {{previous declaration}}
> -void r6() throw(int); // expected-error {{exception specification in declaration does not match}}
> -
>  void r7() throw(int); // expected-note {{previous declaration}}
>  void r7() throw(float); // expected-error {{exception specification in declaration does not match}}
>
> @@ -89,8 +83,6 @@
>  struct Base
>  {
>   virtual void f1() throw();
> -  virtual void f2();
> -  virtual void f3() throw(...);
>   virtual void f4() throw(int, float);
>
>   virtual void f5() throw(int, float);
> @@ -107,8 +99,6 @@
>  struct Derived : Base
>  {
>   virtual void f1() throw();
> -  virtual void f2() throw(...);
> -  virtual void f3();
>   virtual void f4() throw(float, int);
>
>   virtual void f5() throw(float);
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>




More information about the cfe-commits mailing list