summaryrefslogtreecommitdiffstats
path: root/clang/test/Sema/ast-print.c
Commit message (Collapse)AuthorAgeFilesLines
* [AST] Fix loss of enum forward decl from decl contextJoel E. Denny2018-05-301-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | For example, given: enum __attribute__((deprecated)) T *p; -ast-print produced: enum T *p; The attribute was lost because the enum forward decl was lost. Another example is the loss of enum forward decls from C++ namespaces (in MS compatibility mode). The trouble was that the EnumDecl node was suppressed, as revealed by -ast-dump. The suppression of the EnumDecl was intentional in r116122, but I don't understand why. The suppression isn't needed for the test suite to behave. Reviewed by: rsmith Differential Revision: https://reviews.llvm.org/D46846 llvm-svn: 333574
* [AST] Fix printing tag decl groups in decl contextsJoel E. Denny2018-05-151-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For example, given: struct T1 { struct T2 *p0; }; -ast-print produced: struct T1 { struct T2; struct T2 *p0; }; Compiling that produces a warning that the first struct T2 declaration does not declare anything. Details: A tag decl group is one or more decls that share a type specifier that is a tag decl (that is, a struct/union/class/enum decl). Within functions, the parser builds such a tag decl group as part of a DeclStmt. However, in decl contexts, such as file scope or a member list, the parser does not group together the members of a tag decl group. Previously, detection of tag decl groups during printing was implemented but only if the tag decl was unnamed. Otherwise, as in the above example, the members of the group did not print together and so sometimes introduced warnings. This patch extends detection of tag decl groups in decl contexts to any tag decl that is recorded in the AST as not free-standing. Reviewed by: rsmith Differential Revision: https://reviews.llvm.org/D45465 llvm-svn: 332314
* [Attr] Print enum attributes at correct positionJoel E. Denny2018-04-241-7/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For example, given: void fn() { enum __attribute__((deprecated)) T *p; } -ast-print produced: void fn() { enum T __attribute__((deprecated(""))) *p; } -ast-print on that produced: void fn() { enum T *p __attribute__((deprecated(""))); } The attribute is on enum T in the first case, but it's on p in the other cases. Details: Within enum declarations, enum attributes were always printed after the tag and any member list. When no member list was present but the enum was a type specifier in a variable declaration, the attribute then applied to the variable not the enum, changing the semantics. This patch fixes that by always printing attributes between the enum's keyword and tag, as clang already does for structs, unions, and classes. Reviewed By: rsmith Differential Revision: https://reviews.llvm.org/D45456 llvm-svn: 330722
* [DeclPrinter] Fix two cases that crash clang -ast-print.Artem Belevich2018-01-171-0/+4
| | | | | | | | | | | | | Both are related to handling anonymous structures. * clang didn't handle () around an anonymous struct variable. * clang also crashed on syntax errors that could lead to other syntactic constructs following the declaration of an anonymous struct. While the code is invalid, that's not a good reason to panic compiler. Differential Revision: https://reviews.llvm.org/D41788 llvm-svn: 322742
* [AST Printer] Print attributes on enum constantsJordan Rose2017-01-201-0/+9
| | | | | | | The AST printer was dropping attributes on enumerators (enum constants). Now it's not. llvm-svn: 292571
* Fix printing of anonymous struct typedefs.Steven Watanabe2016-03-181-0/+2
| | | | | | | | | | | | | | | | | | | | | | clang -cc1 -ast-print put the struct definition in the wrong place, like this: struct {} typedef S; The reason that this happens is that the printing code first prints the struct definition, and then tells the next declaration to leave out the type. This behavior is correct for simple variable declarations, but fails for typedefs (or extern, mutable, etc). The patch address this problem by skipping the struct declaration when we first see it, and then telling the first subsequent declaration that it needs to print out the full struct definition. Differential Revision: http://reviews.llvm.org/D17285 llvm-svn: 263836
* Fix printing of types in initializers with suppressed tags.Benjamin Kramer2016-01-251-0/+10
| | | | | | | | | | | | | | | | | | Tag and specifier printing can be suppressed in Decl::printGroup, but these suppressions leak into the initializers. Thus int *x = ((void *)0), *y = ((void *)0); gets printed as int *x = ((void *)0), *y = ((*)0); And struct { struct Z z; } z = {(struct Z){}}; gets printed as struct { struct Z z; } z = {(){}}; The stops the suppressions from leaking into the initializers. Patch by Nick Sumner! Differential Revision: http://reviews.llvm.org/D16438 llvm-svn: 258679
* Move target-specific Sema test to its own file.Jonathan Roelofs2015-06-091-6/+0
| | | | | | Fixing the build-break introduced in r239406. llvm-svn: 239407
* Fix printing of GCCAsmExprs with input or output arguments.Jonathan Roelofs2015-06-091-0/+6
| | | | | | Patch by Nick Sumner! llvm-svn: 239406
* AST: Fix printing GNU old-style field designatorsJustin Bogner2015-05-281-0/+8
| | | | | | | | | | | | Allows StmtPrinter to print old style field designators in initializers, fixing an issue where we would print the following invalid code: struct A a = {b: = 3, .c = 4}; Patch by Nick Sumner. Thanks! llvm-svn: 238517
* Pretty print attributes associated with record declarations.Aaron Ballman2014-09-151-0/+3
| | | | llvm-svn: 217784
* The GNU-style aligned attribute has an optional expression, but the ↵Aaron Ballman2014-08-011-0/+3
| | | | | | | | generated pretty printing logic was unaware of this. Fixed the pretty printing logic, and added a test to ensure it no longer asserts. Added a FIXME to the code about eliding the parenthesis when pretty printing such a construct. llvm-svn: 214513
* TypePrinter should not ignore IndexTypeCVRQualifiers on constant-sized arraysHal Finkel2014-07-191-0/+10
| | | | | | | | | | C99 array parameters can have index-type CVR qualifiers, and the TypePrinter should print them when present (and we were not for constant-sized arrays). Otherwise, we'd drop the restrict in: int foo(int a[restrict static 3]) { ... } llvm-svn: 213445
* TypePrinter should not omit the static keyword in array parameter declaratorsHal Finkel2014-07-181-0/+11
| | | | | | | | | | | In C99, an array parameter declarator might have the form: direct-declarator '[' 'static' type-qual-list[opt] assign-expr ']' and when the size of the array is a constant, don't omit the static keyword when printing the type. Also, in the VLA case, put a space after the static keyword (some assignment expression must follow it). llvm-svn: 213424
* Correct printing of nested anonymous type member accesses.David Blaikie2012-11-121-1/+13
| | | | | | Patch by Florent Bruneau! llvm-svn: 167736
* Update tests to use %clang_cc1 instead of 'clang-cc' or 'clang -cc1'.Daniel Dunbar2009-12-151-1/+1
| | | | | | | | | - This is designed to make it obvious that %clang_cc1 is a "test variable" which is substituted. It is '%clang_cc1' instead of '%clang -cc1' because it can be useful to redefine what gets run as 'clang -cc1' (for example, to set a default target). llvm-svn: 91446
* Rename clang to clang-cc.Daniel Dunbar2009-03-241-1/+1
| | | | | | Tests and drivers updated, still need to shuffle dirs. llvm-svn: 67602
* Fix a bug handling typedefs of functions, patch by Nuno Lopes!Chris Lattner2007-12-061-0/+2
| | | | llvm-svn: 44661
* Fix an ast-print/ast-dump bug.Chris Lattner2007-12-031-0/+6
llvm-svn: 44550
OpenPOWER on IntegriCloud