Commit Graph

2060 Commits

Author SHA1 Message Date
Rafael Espindola 8778c28022 Merge function types in C.
Among other differences, GCC accepts

  typedef int IA[];
  typedef int A10[10];
  static A10 *f(void);
  static IA  *f(void);
  void g(void) {
    (void)sizeof(*f());
  }

but clang used to reject it with:

  invalid application of 'sizeof' to an incomplete type 'IA' (aka 'int []')

The intention of c99's 6.2.7 seems to be that we should use the composite type
and accept as gcc does.

Doing the type merging required some extra fixes:
  * Use the type from the function type in initializations, even if an parameter
    is available.
  * Fix the merging of the noreturn attribute in function types.
  * Make CodeGen  handle the fact that an parameter type can be different from
    the corresponding type in the function type.

llvm-svn: 168895
2012-11-29 16:09:03 +00:00
Richard Smith e6a56db2e6 Reject uses of __int128 on platforms that don't support it. Also move the ugly
'getPointerWidth(0) >= 64' test to be a method on TargetInfo, ready to be
properly cleaned up.

llvm-svn: 168856
2012-11-29 05:41:51 +00:00
Eli Friedman 6fdc1221c7 Test for r168674.
llvm-svn: 168675
2012-11-27 02:58:49 +00:00
Rafael Espindola 9c235640e1 Add a testcase that r168411 would break.
llvm-svn: 168669
2012-11-27 01:56:54 +00:00
Rafael Espindola 53192e7d93 Check that we don't warn on this testcase. This is basically a test that
Decl::isUsed checks the attribute. If the function had a body just the check
is DeclMustBeEmitted would be sufficient.

llvm-svn: 168514
2012-11-23 13:54:40 +00:00
NAKAMURA Takumi 3424550294 clang/test/Sema/warn-documentation.cpp: Try to fix up the testcase in r168277.
llvm-svn: 168278
2012-11-18 02:34:33 +00:00
Dmitri Gribenko 76b91c3431 Documentation parsing: propely handle a lone '\endverbatim' and emit a warning.
We actually used to assert on this.

Thanks to NAKAMURA Takumi for noticing this!

llvm-svn: 168277
2012-11-18 00:30:31 +00:00
Andy Gibbs a8df57a962 Made the "expected string literal" diagnostic more expressive
llvm-svn: 168267
2012-11-17 19:16:52 +00:00
Eli Friedman 6745c3b732 Fix a trivial bool-related bug I spotted while skimming David Fang's
current list of powerpc-darwin8 failures.

llvm-svn: 168016
2012-11-15 01:21:59 +00:00
David Blaikie 8fab8e53fb Correct printing of nested anonymous type member accesses.
Patch by Florent Bruneau!

llvm-svn: 167736
2012-11-12 19:12:12 +00:00
Benjamin Kramer d0b9f090fb Set TLSSupported to false on Haiku.
Haiku does not support this (yet). Leaving it set to true leads to
configure scripts detecting __thread being available and Clang emitting
code for it, resulting in binaries the runtime_loader will refuse to
load.

Patch by Jonathan Schleifer!

llvm-svn: 167576
2012-11-08 12:59:15 +00:00
Dmitri Gribenko 5ac744e006 Handle CK_NullToPointer casts in -Wtype-safety properly. Fixes PR14249.
llvm-svn: 167358
2012-11-03 16:07:49 +00:00
Eli Friedman 8f88f06dd2 Tweak wording and add diagnostic groups to misc diagnostics.
llvm-svn: 167274
2012-11-02 01:40:23 +00:00
Quentin Colombet 4e172067b2 Update the front end to use minsize attribute
llvm-svn: 167266
2012-11-01 23:55:47 +00:00
Chad Rosier 0130f82ccc [ms-inline asm] Add test case for r166792.
llvm-svn: 166793
2012-10-26 18:33:59 +00:00
David Tweed 89206b6214 These tests require an actual x86 registered target, so mark them as such. Tested on ARM.
Patch by Joey Gouly.

llvm-svn: 166765
2012-10-26 10:17:44 +00:00
Bill Wendling 208f61913d Fix grammar-o.
llvm-svn: 166759
2012-10-26 07:02:46 +00:00
Eli Friedman 82dc260385 Add an additional test for namespaces and -Wmissing-variable-declarations. Move C++ test into SemaCXX.
llvm-svn: 166616
2012-10-24 20:14:09 +00:00
Matt Beaumont-Gay 53e767bf6b Address feedback from Eli Friedman on r166522.
In particular, we do want to warn on some unused cast subexpressions within
macros.

llvm-svn: 166534
2012-10-24 01:14:28 +00:00
Matt Beaumont-Gay 493d6d55ba Don't emit -Wunused-value warnings from macro expansions.
llvm-svn: 166522
2012-10-23 23:19:32 +00:00
Eli Friedman 4e2e13edb7 Delete junk that snuck into r166498.
llvm-svn: 166499
2012-10-23 20:23:23 +00:00
Eli Friedman 7d14b3c9b3 Add a new warning -Wmissing-variable-declarations, to warn about variables
defined without a previous declaration.  This is similar to
-Wmissing-prototypes, but for variables instead of functions.

Patch by Ed Schouten.

llvm-svn: 166498
2012-10-23 20:19:32 +00:00
Eli Friedman d5d136be5b [ms-inline-asm] Add handling for errors coming out of the backend.
llvm-svn: 166463
2012-10-23 02:43:30 +00:00
David Blaikie 82d3ab9225 Clarify wording of -Wshift-op-parentheses.
Suggestion from Matt Beaumont-Gay reviewing r165283.

llvm-svn: 166296
2012-10-19 18:26:06 +00:00
Andy Gibbs c6e68daac0 Prior to adding the new "expected-no-diagnostics" directive to VerifyDiagnosticConsumer, make the necessary adjustment to 580 test-cases which will henceforth require this new directive.
llvm-svn: 166280
2012-10-19 12:44:48 +00:00
Andy Gibbs ac51de6ec2 Fix directive parsing in VerifyDiagnosticConsumer so that it ensures that "expected" is at the start of the word and will no longer accept typos such as "junkexpected-*" as a valid "expected-*" directive. A very few test-cases had to be amended to adhere to the new rule.
Patch reviewed by David Blaikie.

llvm-svn: 166279
2012-10-19 12:36:49 +00:00
Derek Schuff a202096dc0 Add pnaclcall convention to Native Client targets.
Because PNaCl bitcode must be target-independent, it uses some
different bitcode representations from other targets (e.g. byval and
sret for structures). This means that without additional type
information, it cannot meet some native ABI requirements for some
targets (e.g. passing structures containing unions by value on
x86-64). To allow generation of code which uses the correct native
ABIs, we also support triples such as x86_64-nacl, which uses
target-dependent IR (as opposed to le32-nacl, which uses byval and
sret).

To allow interoperation between the two types of code, this patch adds
a calling convention attribute to be used in code compiled with the
target-dependent triple, which will generate code using the le32-style
bitcode. This calling convention does not need to be explicitly
supported in the backend because it determines bitcode representation
rather than native conventions (the backend just needs to undersand
how to handle byval and sret for the Native Client OS).

This patch implements __attribute__((pnaclcall)) to generate calls in
bitcode according to the le32 bitcode conventions, an attribute which
is accepted by any Native Client target, but issues a warning
otherwise.

llvm-svn: 166065
2012-10-16 22:30:41 +00:00
David Blaikie 282ad876bd Implement GCC's -Wint-to-pointer-cast.
This implementation doesn't warn on anything that GCC doesn't warn on with the
exception of templates specializations (GCC doesn't warn, Clang does). The
specific skipped cases (boolean, constant expressions, enums) are open for
debate/adjustment if anyone wants to demonstrate that GCC is being overly
conservative here. The only really obvious false positive I found was in the
Clang regression suite's MPI test - apparently MPI uses specific flag values in
pointer constants. (eg: #define FOO (void*)~0)

llvm-svn: 166039
2012-10-16 18:53:14 +00:00
Eli Friedman 9ee2d04753 Make -mms-bitfields behave consistently.
Patch by Jeremiah Zanin.

llvm-svn: 165849
2012-10-12 23:29:20 +00:00
Logan Chien 57086ce248 Fix PR 11709: Change the definition of va_list to meet AAPCS requirement
AAPCS ABI Section 7.1.4 [1] specifies that va_list
should be defined as struct __va_list { void *__ap;};
And in C++, it is defined in namespace std.

[1] http://infocenter.arm.com/help/topic
         /com.arm.doc.ihi0042d/IHI0042D_aapcs.pdf

Patch by Weiming Zhao.

llvm-svn: 165609
2012-10-10 06:56:20 +00:00
Eli Friedman ae8ee25d8d Make sure we allow "#pragma options align=mac68k" in function-local contexts. <rdar://problem/12453134>
llvm-svn: 165462
2012-10-08 23:52:38 +00:00
David Blaikie dac86fd24c Use a single note diagnostic for all the precedent/parentheses warnings.
llvm-svn: 165384
2012-10-08 01:19:49 +00:00
Benjamin Kramer a801f4a81d Expose __builtin_bswap16.
GCC has always supported this on PowerPC and 4.8 supports it on all platforms,
so it's a good idea to expose it in clang too. LLVM supports this on all targets.

llvm-svn: 165362
2012-10-06 14:42:22 +00:00
Aaron Ballman 57f590e674 Changing line endings from Windows to Unix. No functional changes.
llvm-svn: 165329
2012-10-05 19:46:32 +00:00
David Blaikie 15f17cbbd8 Implement -Wshift-op-parentheses for: a << b + c
This appears to be consistent with GCC's implementation of the same warning
under -Wparentheses. Suppressing a << b + c for cases where 'a' is a user
defined type for compatibility with C++ stream IO. Otherwise suggest
parentheses around the addition or subtraction subexpression.

(this came up when MSVC was complaining (incorrectly, so far as I can tell)
about a perceived violation of this within the LLVM codebase, PR14001)

llvm-svn: 165283
2012-10-05 00:41:03 +00:00
Eli Friedman 68be1649ee Permanently end the whole "pragma got handled by the parser too early"
mess by handling all pragmas which the parser touches uniformly.
<rdar://problem/12248901>, etc.

llvm-svn: 165195
2012-10-04 02:36:51 +00:00
Aaron Ballman a99c35702d Splitting this test case into two because the behavior for the calling convention code is target-specific.
llvm-svn: 165016
2012-10-02 14:56:00 +00:00
Aaron Ballman e91c6be01e Allowing individual targets to determine whether a given calling convention is allowed or ignored with warning. This allows for correct name mangling for x64 targets on Windows, which in turn allows for linking against the Win32 APIs.
Fixes PR13782

llvm-svn: 165015
2012-10-02 14:26:08 +00:00
Fariborz Jahanian c491c3f27a availability in structured documents. Takes
care of comments by Dimitri and Doug.

llvm-svn: 164957
2012-10-01 18:42:25 +00:00
Dmitri Gribenko 6743e04699 Move the 'find macro by spelling' infrastructure to the Preprocessor class and
use it to suggest appropriate macro for __attribute__((deprecated)) in
-Wdocumentation-deprecated-sync.

llvm-svn: 164892
2012-09-29 11:40:46 +00:00
Richard Smith 80ac9efec4 Allow __builtin_bswap32/64 in constant expressions, like gcc does. Patch by Tijl Coosemans!
llvm-svn: 164841
2012-09-28 20:20:52 +00:00
Nico Weber f666b2a547 Make this test actually test something
llvm-svn: 164677
2012-09-26 09:02:07 +00:00
Hans Wennborg c980408c71 Fix failing test/Sema/wchar.c on ARM.
Currently Sema/wchar.c fails because WCHAR_T_TYPE is defined as int,
however on ARM wchar_t is unsigned int.

This patch changes that, so this test passes for ARM.

Patch by Joey Gouly!

llvm-svn: 164598
2012-09-25 10:11:17 +00:00
Bob Wilson 317be45091 Replace an assertion with an error for empty __asm statements.
llvm-svn: 164551
2012-09-24 19:57:59 +00:00
Dmitri Gribenko 1cd2305703 Change the wording of the extension warning from
> 'long long' is an extension when C99 mode is not enabled
to
> 'long long' is a C++11 extension
while compiling in C++98 mode.

llvm-svn: 164545
2012-09-24 18:19:21 +00:00
Dmitri Gribenko 1da8886915 Comment sema: warn when comment has \deprecated but declaration does not have a
deprecation attribute ('deprecated', 'availability' or 'unavailable').

This warning is under a separate flag, -Wdocumentation-deprecated-sync, so it
can be turned off easily while leaving other -Wdocumentation warnings on.

llvm-svn: 164467
2012-09-22 21:47:50 +00:00
Abramo Bagnara 6cba23a649 Avoid multiple atomic builtin declaration.
llvm-svn: 164454
2012-09-22 09:05:22 +00:00
Fariborz Jahanian 2f4e33aba2 Improvements to my patch in r164143 per
Richard's comments. // rdar://12202422

llvm-svn: 164316
2012-09-20 19:36:41 +00:00
David Blaikie 6590220181 Include types when a definition's type differs from a prior declaration.
This is some really old code (took me a while to find the test cases) & the
diagnostic text is slightly incorrect (it should really only apply to
re/declarations/, redefinitions are an error regardless of whether the types
match). Not sure if anyone cares about it, though.

For now this just makes the diagnostic more clear in less obvious cases where
the type of a declaration might not be explicitly written (eg: because it
uses decltype)

llvm-svn: 164313
2012-09-20 18:38:57 +00:00
Richard Smith b6d516e7bd PR13881: Add -Wzero-length-array for zero length array extension, and move it into -Wgnu.
llvm-svn: 164272
2012-09-20 01:02:05 +00:00