Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

[ms] Unsupported Source-code Annotation Language #27028

Open Quuxplusone opened 8 years ago

Quuxplusone commented 8 years ago
Bugzilla Link PR27029
Status NEW
Importance P normal
Reported by Egor (hrulikus@ya.ru)
Reported on 2016-03-22 07:30:24 -0700
Last modified on 2017-12-06 06:02:32 -0800
Version trunk
Hardware PC Windows NT
CC dmitry.polukhin@gmail.com, hrulikus@ya.ru, llvm-bugs@lists.llvm.org, rnk@google.com, zahira.ammarguellat@intel.com
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also
This report is about MSVC feature Source-code annotation language which
provides a set of annotations to describe how a function uses its parameters,
for example, the assumptions it makes about them and the guarantees it makes on
finishing. So clang does not support this feature

====================ENVIRONMENT==================
OS: Windows
Version: trunk

=================SMALL REPRODUCER======================
typedef unsigned short wchar_t;
[source_annotation_attribute( SA_All )]
struct AnnotesAttribute
{
        wchar_t *Name;
        wchar_t *p1;
};
typedef struct AnnotesAttribute  SAL_annotes;
typedef struct _XSTATE_CONTEXT {

    [SAL_annotes(Name="SAL_null", p1="__maybe")] [SAL_annotes(Name="SAL_writableTo", p1="byteCount(L
ength)")] int A;

};
=================ERROR==============================
>>> MSVC:
 compiles this code successfully

>>>clang:
$ clang-cl -c test.c

test.c:12:5: error: type name requires a specifier or qualifier
    [SAL_annotes(Name="SAL_null", p1="__maybe")] [SAL_annotes(Name="SAL_...
    ^
test.c:12:6: error: unexpected type name 'SAL_annotes': expected expression
    [SAL_annotes(Name="SAL_null", p1="__maybe")] [SAL_annotes(Name="SAL_...
     ^
test.c:12:18: error: use of undeclared identifier 'Name'
    [SAL_annotes(Name="SAL_null", p1="__maybe")] [SAL_annotes(Name="SAL_...
                 ^
test.c:12:35: error: use of undeclared identifier 'p1'
    [SAL_annotes(Name="SAL_null", p1="__maybe")] [SAL_annotes(Name="SAL_...
                                  ^
test.c:12:51: error: unexpected type name 'SAL_annotes': expected expression
    [SAL_annotes(Name="SAL_null", p1="__maybe")] [SAL_annotes(Name="SAL_...
                                                  ^
test.c:12:63: error: use of undeclared identifier 'Name'
    [SAL_annotes(Name="SAL_null", p1="__maybe")] [SAL_annotes(Name="SAL_...
                                                              ^
test.c:12:86: error: use of undeclared identifier 'p1'
  ...p1="__maybe")] [SAL_annotes(Name="SAL_writableTo", p1="byteCount(Length)...
                                                        ^
test.c:12:111: error: expected member name or ';' after declaration
      specifiers
  ...[SAL_annotes(Name="SAL_writableTo", p1="byteCount(Length)")] int Area;
                                                                  ^
test.c:12:110: error: expected ';' at end of declaration list
  ...[SAL_annotes(Name="SAL_writableTo", p1="byteCount(Length)")] int Area;
                                                                 ^
                                                                 ;

==============================================
Egor Khrulev
Software Engineer
Intel Compiler Team
Quuxplusone commented 8 years ago

Is this a feature request to leverage SAL for better static analysis, or to parse and ignore SAL so that normal compilation can occur?

Quuxplusone commented 8 years ago

I think Clang should just parse SAL and ignore so user could use Clang as drop-in replacement for MSVC.