Changeset 4d860ea3


Ignore:
Timestamp:
Oct 6, 2023, 2:58:48 PM (14 months ago)
Author:
Michael Brooks <mlbrooks@…>
Branches:
master
Children:
500a60f
Parents:
0860d9c
Message:

Fix compiler bug where duplicate type declarations caused crash.

And add missing test. The test runs and fails with the previous cfa compiler.

Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • src/Validate/NoIdSymbolTable.hpp

    r0860d9c r4d860ea3  
    2020namespace Validate {
    2121
    22 // A SymbolTable that only has the operations used in the Translate Dimension
    23 // pass. More importantly, it doesn't have some methods that should no be
     22// A SymbolTable that only tracks names relevant to Validate passes.
     23// It tracks type names but not identifier names.
     24// Some of the canonicalization that occurs before the resolver
     25// affects how identifier name errors get reported to the user.
     26// The Validate phase needs to chase type names,
     27// but it is too early to try tracking identifier names.
     28// Identifier skipping is acheived by omitting methods that should not be
    2429// called by the Pass template (lookupId and addId).
    2530class NoIdSymbolTable {
    2631        ast::SymbolTable base;
    2732public:
     33        // All names that are tracked (now) are eligible for collision validation (now).
     34        // (Names that are only tracked later get their collision validation then.)
     35        NoIdSymbolTable() : base(ast::SymbolTable::ValidateOnAdd) {}
     36
    2837#       define FORWARD_X( func, types_and_names, just_names ) \
    2938        inline auto func types_and_names -> decltype( base.func just_names ) { \
  • tests/errors/.expect/scope.txt

    r0860d9c r4d860ea3  
    1 errors/scope.cfa:2:1 error: duplicate object definition for thisIsAnError: signed int
    2 errors/scope.cfa:20:1 error: duplicate function definition for butThisIsAnError: function
     1errors/scope.cfa:13:1 error: duplicate object definition for thisIsAnError: signed int
     2errors/scope.cfa:30:1 error: duplicate function definition for butThisIsAnError: function
    33... with parameters
    44  double
  • tests/errors/scope.cfa

    r0860d9c r4d860ea3  
    1 int thisIsAnError;
    2 int thisIsAnError;
     1// Keep harmonized with errors/scope.
    32
    4 int thisIsNotAnError;
    5 float thisIsNotAnError;
     3#ifdef OMIT_DRIVING_REJECTIONS
     4// For manual sanity checking:
     5// Leave out the offensive declarations and verify that what's left is accepted.
     6#define EXPREJ(...)
     7#else
     8#define EXPREJ(...) __VA_ARGS__
     9#endif
    610
    7 int thisIsAlsoNotAnError() {
    8   int thisIsNotAnError;
    9 }
    1011
    11 int thisIsAlsoNotAnError( double x ) {
    12 }
     12        int thisIsAnError;
     13EXPREJ( int thisIsAnError; )
    1314
    14 double thisIsStillNotAnError( double );
    15 double thisIsStillNotAnError( double );
     15        int thisIsNotAnError;
     16        float thisIsNotAnError;
    1617
    17 double butThisIsAnError( double ) {
    18 }
     18        int thisIsAlsoNotAnError() {
     19          int thisIsNotAnError;
     20        }
    1921
    20 double butThisIsAnError( double ) {
    21 }
     22        int thisIsAlsoNotAnError( double x ) {
     23        }
     24
     25        double thisIsStillNotAnError( double );
     26        double thisIsStillNotAnError( double );
     27
     28        double butThisIsAnError( double ) {
     29        }
     30EXPREJ(
     31        double butThisIsAnError( double ) {
     32        }
     33)
    2234
    2335// Local Variables: //
Note: See TracChangeset for help on using the changeset viewer.