llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
27.84k stars 11.46k forks source link

[ms] Unsupported Source-code Annotation Language #27403

Open llvmbot opened 8 years ago

llvmbot commented 8 years ago
Bugzilla Link 27029
Version trunk
OS Windows NT
Reporter LLVM Bugzilla Contributor
CC @dmpolukhin,@rnk,@zahiraam

Extended Description

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")] [SALannotes(Name="SAL... ^ test.c:12:6: error: unexpected type name 'SAL_annotes': expected expression [SAL_annotes(Name="SAL_null", p1="maybe")] [SALannotes(Name="SAL... ^ test.c:12:18: error: use of undeclared identifier 'Name' [SAL_annotes(Name="SAL_null", p1="maybe")] [SALannotes(Name="SAL... ^ test.c:12:35: error: use of undeclared identifier 'p1' [SAL_annotes(Name="SAL_null", p1="__maybe")] [SALannotes(Name="SAL... ^ test.c:12:51: error: unexpected type name 'SAL_annotes': expected expression [SAL_annotes(Name="SAL_null", p1="maybe")] [SALannotes(Name="SAL... ^ test.c:12:63: error: use of undeclared identifier 'Name' [SAL_annotes(Name="SAL_null", p1="maybe")] [SALannotes(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

dmpolukhin commented 8 years ago

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

rnk 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?