r180603 - C++1y: support simple variable assignments in constexpr functions.

Abramo Bagnara abramo.bagnara at bugseng.com
Sun May 5 02:53:30 PDT 2013


Il 26/04/2013 16:36, Richard Smith ha scritto:
> Modified: cfe/trunk/lib/Sema/SemaInit.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=180603&r1=180602&r2=180603&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Sema/SemaInit.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaInit.cpp Fri Apr 26 09:36:30 2013
> @@ -97,6 +97,7 @@ static void CheckStringInit(Expr *Str, Q
>      DeclT = S.Context.getConstantArrayType(IAT->getElementType(),
>                                             ConstVal,
>                                             ArrayType::Normal, 0);
> +    Str->setType(DeclT);
>      return;
>    }

Is this change deliberate? It seems to introduce a regression:

$ cat z.c

void f() {
  signed char s[] = "a";
  unsigned char u[] = "a";
}
$ _clang -cc1 -ast-dump z.c
TranslationUnitDecl 0x67d96e0 <<invalid sloc>>
|-TypedefDecl 0x67d9bc0 <<invalid sloc>> __int128_t '__int128'
|-TypedefDecl 0x67d9c20 <<invalid sloc>> __uint128_t 'unsigned __int128'
|-TypedefDecl 0x67d9f70 <<invalid sloc>> __builtin_va_list
'__va_list_tag [1]'
`-FunctionDecl 0x67da010 <z.c:2:1, line:5:1> f 'void ()'
  `-CompoundStmt 0x67da350 <line:2:10, line:5:1>
    |-DeclStmt 0x67da208 <line:3:3, col:24>
    | `-VarDecl 0x67da100 <col:3, col:21> s 'signed char [2]'
    |   `-StringLiteral 0x67da198 <col:21> 'signed char [2]' lvalue "a"
    `-DeclStmt 0x67da338 <line:4:3, col:26>
      `-VarDecl 0x67da270 <col:3, col:23> u 'unsigned char [2]'
        `-StringLiteral 0x67da2c8 <col:23> 'unsigned char [2]' lvalue "a"

Type of string literal should be plain char.



More information about the cfe-commits mailing list