[cfe-commits] r102464 - in /cfe/trunk: lib/AST/ASTContext.cpp test/Sema/attr-regparm.c

Daniel Dunbar daniel at zuster.org
Wed Apr 28 09:15:10 PDT 2010


Hi Eli,

I am about to revert this, it breaks a lot of project builds. I don't
have a test case handy, but they all seem to involve noreturn. This is
the ClamAV failure, for example:
--
clamdtop.c:435:24: error: conflicting types for 'exit_program'
static void __noreturn exit_program(enum exit_reason reason, const
char *func, unsigned line)
                       ^
clamdtop.c:113:13: note: previous declaration is here
static void exit_program(enum exit_reason reason, const char *func,
unsigned line);
            ^
--

 - Daniel

On Tue, Apr 27, 2010 at 2:07 PM, Eli Friedman <eli.friedman at gmail.com> wrote:
> Author: efriedma
> Date: Tue Apr 27 16:07:06 2010
> New Revision: 102464
>
> URL: http://llvm.org/viewvc/llvm-project?rev=102464&view=rev
> Log:
> Fix for PR6953: per gcc, regparm and noreturn affect the compatibility of
> function types.
>
> This could potentially have unexpected side-effects, so look here if there are
> new regressions.
>
>
> Modified:
>    cfe/trunk/lib/AST/ASTContext.cpp
>    cfe/trunk/test/Sema/attr-regparm.c
>
> Modified: cfe/trunk/lib/AST/ASTContext.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=102464&r1=102463&r2=102464&view=diff
> ==============================================================================
> --- cfe/trunk/lib/AST/ASTContext.cpp (original)
> +++ cfe/trunk/lib/AST/ASTContext.cpp Tue Apr 27 16:07:06 2010
> @@ -4311,21 +4311,16 @@
>     allLTypes = false;
>   if (getCanonicalType(retType) != getCanonicalType(rbase->getResultType()))
>     allRTypes = false;
> -  // FIXME: double check this
> -  // FIXME: should we error if lbase->getRegParmAttr() != 0 &&
> -  //                           rbase->getRegParmAttr() != 0 &&
> -  //                           lbase->getRegParmAttr() != rbase->getRegParmAttr()?
> +
> +  // Check misc function attributes
>   FunctionType::ExtInfo lbaseInfo = lbase->getExtInfo();
>   FunctionType::ExtInfo rbaseInfo = rbase->getExtInfo();
> -  unsigned RegParm = lbaseInfo.getRegParm() == 0 ? rbaseInfo.getRegParm() :
> -      lbaseInfo.getRegParm();
> -  bool NoReturn = lbaseInfo.getNoReturn() || rbaseInfo.getNoReturn();
> -  if (NoReturn != lbaseInfo.getNoReturn() ||
> -      RegParm != lbaseInfo.getRegParm())
> -    allLTypes = false;
> -  if (NoReturn != rbaseInfo.getNoReturn() ||
> -      RegParm != rbaseInfo.getRegParm())
> -    allRTypes = false;
> +  // Per gcc, compatible functions must have compatible regparm and noreturn
> +  // attributes.
> +  unsigned RegParm = lbaseInfo.getRegParm();
> +  bool NoReturn = lbaseInfo.getNoReturn();
> +  if (NoReturn != rbaseInfo.getNoReturn() || RegParm != rbaseInfo.getRegParm())
> +    return QualType();
>   CallingConv lcc = lbaseInfo.getCC();
>   CallingConv rcc = rbaseInfo.getCC();
>   // Compatible functions must have compatible calling conventions
>
> Modified: cfe/trunk/test/Sema/attr-regparm.c
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/attr-regparm.c?rev=102464&r1=102463&r2=102464&view=diff
> ==============================================================================
> --- cfe/trunk/test/Sema/attr-regparm.c (original)
> +++ cfe/trunk/test/Sema/attr-regparm.c Tue Apr 27 16:07:06 2010
> @@ -1,7 +1,11 @@
>  // RUN: %clang_cc1 -triple i386-apple-darwin9 -fsyntax-only -verify %s
>
> -__attribute((regparm(2))) int x(void);
> -__attribute((regparm(1.0))) int x(void); // expected-error{{'regparm' attribute requires integer constant}}
> -__attribute((regparm(-1))) int x(void); // expected-error{{'regparm' parameter must be between 0 and 3 inclusive}}
> -__attribute((regparm(5))) int x(void); // expected-error{{'regparm' parameter must be between 0 and 3 inclusive}}
> -__attribute((regparm(5,3))) int x(void); // expected-error{{attribute requires 1 argument(s)}}
> +__attribute((regparm(2))) int a(void);
> +__attribute((regparm(1.0))) int b(void); // expected-error{{'regparm' attribute requires integer constant}}
> +__attribute((regparm(-1))) int c(void); // expected-error{{'regparm' parameter must be between 0 and 3 inclusive}}
> +__attribute((regparm(5))) int d(void); // expected-error{{'regparm' parameter must be between 0 and 3 inclusive}}
> +__attribute((regparm(5,3))) int e(void); // expected-error{{attribute requires 1 argument(s)}}
> +int f(void);
> +__attribute((regparm(0))) int f(void);
> +__attribute((regparm(1))) int g(void); // expected-note{{previous declaration is here}}
> +__attribute((regparm(2))) int g(void); // expected-error{{conflicting types for 'g'}}
>
>
> _______________________________________________
> 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